Re: Query is slower with a large proportion of NULLs in several columns

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Query is slower with a large proportion of NULLs in several columns
Дата
Msg-id CAKFQuwZP8KUnLLukbfnxp7uqE5q-8vkOZcZGDhdXxZ0u1eOHpg@mail.gmail.com
обсуждение исходный текст
Ответ на Query is slower with a large proportion of NULLs in several columns  (Lars Bergeson <larsavatar@gmail.com>)
Список pgsql-performance
On Monday, December 20, 2021, Lars Bergeson <larsavatar@gmail.com> wrote:

What is it about null values in the table that slows down the full table scan?

If I populate blank/zero for all of the unused values in columns that are NULLable, the query is fast again. So just defining the columns as NULLable isn't what slows it down -- it's actually the NULL values in the rows that seems to degrade performance.

The presence or absence of the constraint has zero effect on the contents of the page/tuple.  As soon as you have a single null in a row you are adding a null bitmap [1] to the stored tuple.  And now for every single column the system has to check whether a specific column’s value is null or not.  Given the number of columns in your table, that this is noticeable is not surprising.

David J.

В списке pgsql-performance по дате отправления:

Предыдущее
От: Lars Bergeson
Дата:
Сообщение: Query is slower with a large proportion of NULLs in several columns
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Query is slower with a large proportion of NULLs in several columns