[GENERAL] Re: Unable to understand index only scan as it is not happening for one table while it happens for other

2017-06-27 Thread rajan
thanks for the explanation, Gary. - -- Thanks, Rajan. -- View this message in context: http://www.postgresql-archive.org/Unable-to-understand-index-only-scan-as-it-is-not-happening-for-one-table-while-it-happens-for-other-tp5968835p5968976.html Sent from the PostgreSQL - general mailing lis

Re: [GENERAL] Re: Unable to understand index only scan as it is not happening for one table while it happens for other

2017-06-27 Thread Gary Evans
Hi Rajan, I would say that the optimiser has calculated that it would be quicker to sequentially read thought the table to get the 354 rows returned without the limit. By introducing the limit, it is much faster to pick out the first 10 rows using the index. Using an index is usually only quicke

[GENERAL] Re: Unable to understand index only scan as it is not happening for one table while it happens for other

2017-06-27 Thread rajan
Thanks. Now I did the same query, but it is going for *index-only scan* only after I put *limit* localdb=# explain analyse verbose select uid from mm where uid>100 order by uid; QUERY PLAN -

Re: [GENERAL] Re: Unable to understand index only scan as it is not happening for one table while it happens for other

2017-06-27 Thread Albe Laurenz
rajan wrote: > why the index-only scan *works only* with an *order by*? > localdb=# explain analyse verbose select uid from mm where uid>100 *order > by* uid; > QUERY > PLAN > ---

[GENERAL] Re: Unable to understand index only scan as it is not happening for one table while it happens for other

2017-06-27 Thread rajan
Ah! Got it. Thanks. One more question, why the index-only scan *works only* with an *order by*? localdb=# explain analyse verbose select uid from mm where uid>100 *order by* uid; QUERY PLAN