plan cache vs regclass constants

Поиск
Список
Период
Сортировка
От Tom Lane
Тема plan cache vs regclass constants
Дата
Msg-id 19769.1213709975@sss.pgh.pa.us
обсуждение исходный текст
Список pgsql-hackers
The example here
http://archives.postgresql.org/pgsql-novice/2008-06/msg00025.php
shows that we are failing to regenerate cached plans when a table
referenced by a regclass constant is removed.  This is pretty minor
in the big scheme of things, but it's still annoying since there is
code in there that's explicitly intended to make that work (see
fix_scan_expr in setrefs.c).  I looked into why not, and soon
realized that the example case really is 'tablename'::regclass::oid
(ie, a RelabelType node atop a Const) because the constant is an
argument to oideq().  So constant folding reduces that to just a
Const of type OID, and fix_scan_expr doesn't think it's interesting.

I see two ways this might be fixed:

1. Don't constant-fold this particular case.  Costs: very ugly
special case in constant folding, and a tiny execution-time penalty.

2. Make fix_scan_expr treat Consts of type OID like regclass Consts.
Costs: some bogus additions to the list of relation OIDs a plan
depends on, which would occasionally result in unnecessary replans.

Anyone have a preference, or see a third way?  I'm kind of leaning
to #1, but it sure is ugly.
        regards, tom lane


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

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Crash in pgCrypto?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Reducing overhead for repeat de-TOASTing