Re: Slow Count-Distinct Query
От
Shaun Thomas
Тема
Re: Slow Count-Distinct Query
Дата
Msg-id
0683F5F5A5C7FE419A752A034B4A0B979785A92E@sswchi5pmbx2.peak6.net
Ответ на
Slow Count-Distinct Query (Christopher Jackson)
Список
Дерево обсуждения
Slow Count-Distinct Query Christopher Jackson <crjackso@gmail.com>
Re: Slow Count-Distinct Query Shaun Thomas <sthomas@optionshouse.com>
Re: Slow Count-Distinct Query Tom Lane <tgl@sss.pgh.pa.us>
Re: Slow Count-Distinct Query Christopher Jackson <crjackso@gmail.com>
Re: Slow Count-Distinct Query bricklen <bricklen@gmail.com>
Re: Slow Count-Distinct Query Christopher Jackson <crjackso@gmail.com>
Re: Slow Count-Distinct Query Michael Paquier <michael.paquier@gmail.com>
Re: Slow Count-Distinct Query Christopher Jackson <crjackso@gmail.com>
> tl;dr - How can I speed up my count-distinct query? You can't. Doing a count(distinct x) is much different than a count(1), which can simply scan available indexes. To build a distinct, it has to construct an in-memory hash of every valid email, and count the distinct values therein. This will pretty much never be fast, especially with 2M rows involved. I could be wrong about this, and the back-end folks might have a different answer, but I wouldn't hold my breath. -- Shaun Thomas OptionsHouse | 141 W. Jackson Blvd | Suite 400 | Chicago IL, 60604 312-676-8870 sthomas@optionshouse.com ______________________________________________ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email
В списке pgsql-performance по дате отправления