sql - querying view is taking too much time -


we have view table , selecting view taking time. example: select x,y,z view1 taking time load. 1 ok.

if query: select x,y,z view1 x in ('abc') queries in seconds.

if query: select x,y,z view1 x in (select 'abc' table1 y='1234') queries in seconds.

but if query: select x,y,z view1 x in (select x table1 y='1234') taking time query , problem want solve.

by way can think : select x table1 y='1234' returns 'abc' 1 row.

the scenario decsribed above , think reason take time query on third query. have tried joining didn't work.

  • a view not magic piece of time saving code
  • a view macro expanded: no more, no less

so if view has 5 tables , 4 joins, these evaluated every time.

so, question should be:

is there suitable indexing on underlying column in base table generates column x in view?

as last sql, adding in clause , subquery view contents.
note may know 1 row returned optimiser may not because or poor or out of date statistics, and/or bad indexing

my next question

does table1 have indexes satisfy subquery efficiently?

either way, looking @ query plan identify going wrong


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -