Re: Query only slow on first run
От
Craig James
Тема
Re: Query only slow on first run
Дата
Msg-id
474D81A1.20301@emolecules.com
Ответ на
Список
Дерево обсуждения
Query only slow on first run cluster <skrald@amossen.dk>
Re: Query only slow on first run Kevin Kempter <kevin@kevinkempterllc.com>
Re: Query only slow on first run Andrew Sullivan <ajs@crankycanuck.ca>
Re: Query only slow on first run Tom Lane <tgl@sss.pgh.pa.us>
Re: Query only slow on first run cluster <skrald@amossen.dk>
Re: Query only slow on first run "Dave Dutcher" <dave@tridecap.com>
Re: Query only slow on first run cluster <skrald@amossen.dk>
Re: Query only slow on first run "Dave Dutcher" <dave@tridecap.com>
Re: Query only slow on first run "Steinar H. Gunderson" <sgunderson@bigfoot.com>
Re: Query only slow on first run Tom Lane <tgl@sss.pgh.pa.us>
Re: Query only slow on first run "Steinar H. Gunderson" <sgunderson@bigfoot.com>
Re: Query only slow on first run tmp <skrald@amossen.dk>
Re: Query only slow on first run "Dave Dutcher" <dave@tridecap.com>
Re: Query only slow on first run Tom Lane <tgl@sss.pgh.pa.us>
Re: Query only slow on first run Craig James <craig_james@emolecules.com>
Re: Query only slow on first run cluster <skrald@amossen.dk>
Re: Query only slow on first run "Steinar H. Gunderson" <sgunderson@bigfoot.com>
Re: Query only slow on first run cluster <skrald@amossen.dk>
Re: Query only slow on first run Tom Lane <tgl@sss.pgh.pa.us>
Re: Query only slow on first run cluster <skrald@amossen.dk>
Re: Query only slow on first run Tom Lane <tgl@sss.pgh.pa.us>
Re: Query only slow on first run Jean-David Beyer <jeandavid8@verizon.net>
Re: Query only slow on first run "Scott Marlowe" <scott.marlowe@gmail.com>
Re: Query only slow on first run Bill Moran <wmoran@collaborativefusion.com>
tmp wrote: >> what exactly is that >> "random_number" column > > A random float that is initialized when the row is created and never > modified afterwards. The physical row ordering will clearly not match > the random_number ordering. However, other queries uses a row ordering > by the primary key so I don't think it would make much sense to make the > index on random_number a clustering index just in order to speed up this > single query. > >> and why are you desirous of ordering by it? > > In order to simulate a random pick of K rows. See [1]. A trick that I used is to sample the random column once, and create a much smaller table of the first N rows, where N is the sample size you want, and use that. If you need a different N samples each time, you can create a temporary table, put your random N rows into that, do an ANALYZE, and then join to this smaller table. The overall performance can be MUCH faster even though you're creating and populating a whole table, than the plan that Postgres comes up with. This seems wrong-headed (why shouldn't Postgres be able to be as efficient on its own?), but it works. Craig
В списке pgsql-performance по дате отправления