Re: Improve "select count(*)" query - takes more than 30 mins for some large tables
В списке pgsql-admin по дате отправления:
| От | Mladen Gogala |
|---|---|
| Тема | Re: Improve "select count(*)" query - takes more than 30 mins for some large tables |
| Дата | |
| Msg-id | 1eb233ff-90f0-529b-f0cc-fa982f668a8f@gmail.com обсуждение исходный текст |
| Ответ на | Re: Improve "select count(*)" query - takes more than 30 mins for some large tables (Florents Tselai <florents.tselai@gmail.com>) |
| Список | pgsql-admin |
psql “select id from my_table" | sort -u | wc -l
That will be a lot slower than just "select count(*) from my_table". You are delivering data to the user program (psql) and then shipping them to pipe and then processing the output with "wc". Depending on the version, PostgreSQL has very reliable parallelism and can do counting rather quickly. The speed of "select count(*) from my_table" depends on the speed of I/O. Since the table is big, it cannot be cached in the file system cache, so all that you have at your disposal is the raw disk speed. For the smaller machines, NVME is the king. For larger rigs, you should consider something like Pure, XTremIO or NetApp SolidFire. People frequently expect database to do miracles with under par hardware.
-- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com
В списке pgsql-admin по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера