On 07/05/2014 02:17 AM, Thomas Munro wrote: > As an exercise I hacked up the simplest code I could think of that would > demonstrate a faster DISTINCT based on skipping ahead to the next > distinct value in an index-only scan. Please see the attached (extremely > buggy) patch, and the example session below. (It's against my natural > instinct to send such half-baked early hacking phase code to the list, > but thought it would make sense to demo the concept and then seek > advice, warnings, cease and desist notices etc before pressing on down > that route!) I would be most grateful for any feedback you might have.
This is called a Loose Index Scan in our wiki[1] which I believe is based on the terminology used for the same feature in MySQL although I haven't and shan't check. This is a feature I would really like to have. Your benchmarks look promising but unfortunately it blows up for me so I can't really test it. I have not yet read the patch nor debugged to see why, but please do keep up work on this. People more expert than I can tell you whether you're implementing it the right way. [1] http://wiki.postgresql.org/wiki/Loose_indexscan -- Vik -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers