From: | Ryan Murphy <ryanfmurphy(at)gmail(dot)com> |
---|---|
To: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Does having a NULL column automatically exclude the table from the tupleDesc cache? |
Date: | 2017-02-15 16:29:36 |
Message-ID: | CAHeEsBcw6JcGzh6zKqcVJCi-UUAV815AvZr=3tx_kMYNr+s+HA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
I was looking through some of the implementation details of the
heap/tuples, specifically src/include/access/htup_details.h - and I came
across the big macro fastgetattr, and had a question about it. I've
included the code here for clarity and convenience:
#define fastgetattr(tup, attnum, tupleDesc, isnull) \
( \
AssertMacro((attnum) > 0), \
(*(isnull) = false), \
HeapTupleNoNulls(tup) ? \
( \
(tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 ? \
( \
fetchatt((tupleDesc)->attrs[(attnum)-1], \
(char *) (tup)->t_data + (tup)->t_data->t_hoff + \
(tupleDesc)->attrs[(attnum)-1]->attcacheoff) \
) \
: \
nocachegetattr((tup), (attnum), (tupleDesc)) \
) \
: \
( \
att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
( \
(*(isnull) = true), \
(Datum)NULL \
) \
: \
( \
nocachegetattr((tup), (attnum), (tupleDesc)) \
) \
) \
)
My question is this: HeapTupleNoNulls() is run first to see if there are
any columns that can be NULL. It looks like the fetchatt() that uses the
cache in the tupleDesc can only be used if there are no NULLable columns in
the table. Is my understanding correct? Does this mean that there is
significant performance gain by never allowing any column to be null in
your table?
Thanks!
Ryan
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2017-02-15 16:30:47 | error handling in RegisterBackgroundWorker |
Previous Message | Robert Haas | 2017-02-15 16:26:58 | Re: Parallel bitmap heap scan |