[HACKERS] Does having a NULL column automatically exclude the table from thetupleDesc cache?

Поиск
Список
Период
Сортировка
От Ryan Murphy
Тема [HACKERS] Does having a NULL column automatically exclude the table from thetupleDesc cache?
Дата
Msg-id CAHeEsBcw6JcGzh6zKqcVJCi-UUAV815AvZr=3tx_kMYNr+s+HA@mail.gmail.com
обсуждение исходный текст
Ответы Re: [HACKERS] Does having a NULL column automatically exclude the table from the tupleDesc cache?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Parallel bitmap heap scan
Следующее
От: Peter Eisentraut
Дата:
Сообщение: [HACKERS] error handling in RegisterBackgroundWorker