From: Tom Lane <tgl@sss.pgh.pa.us>
To: Lars Bergeson <larsavatar@gmail.com>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Query is slower with a large proportion of NULLs in several columns
Date: Mon, 20 Dec 2021 20:51:59 -0500
Message-ID: <2688019.1640051519@sss.pgh.pa.us> (raw)
In-Reply-To: <CAK66RGYim22Sd8-NvmufcxEQ_P99=UTAyJ9agnwDyEbCiVGEQg@mail.gmail.com>
References: <CAK66RGYim22Sd8-NvmufcxEQ_P99=UTAyJ9agnwDyEbCiVGEQg@mail.gmail.com>
Lars Bergeson <larsavatar@gmail.com> writes:
> What is it about null values in the table that slows down the full table
> scan?
If a row has any nulls, then it contains a "nulls bitmap" [1] that says
which columns are null, and that bitmap has to be consulted while
walking through the row contents. So the most obvious theory here
is that that adds overhead that's significant in your case. But there
are some holes in that theory, mainly that the I/O timings you are
showing don't seem very consistent:
no nulls:
> I/O Timings: read=1884365.335
> Execution Time: 11135.368 ms
with nulls:
> I/O Timings: read=17141420.771
> Execution Time: 25407.318 ms
Regardless of CPU time required, it should not take 10X less I/O
time to read a physically larger table. So there's something
fairly bogus going on there. One thing you might try is disabling
parallelism (set max_parallel_workers_per_gather = 0) to see if
that's confusing the numbers somehow.
regards, tom lane
[1] https://www.postgresql.org/docs/current/storage-page-layout.html#STORAGE-TUPLE-LAYOUT
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, larsavatar@gmail.com, pgsql-performance@lists.postgresql.org
Subject: Re: Query is slower with a large proportion of NULLs in several columns
In-Reply-To: <2688019.1640051519@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox