Re: tableam: abstracting relation sizing code

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: tableam: abstracting relation sizing code
Дата
Msg-id CA+Tgmob36b4rznk3NEeh_GV=bGyW6Y6DhGD=D_Bwwa=7pQCkMQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: tableam: abstracting relation sizing code  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: tableam: abstracting relation sizing code  (Daniel Gustafsson <daniel@yesql.se>)
Re: tableam: abstracting relation sizing code  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
On Mon, Jun 10, 2019 at 3:46 PM Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> I agree that you're just moving the code, but this seems to have been
> recently broken in 696d78469f37 -- it was correct before that (the
> heuristic for never vacuumed rels was in optimizer/plancat.c).  So in
> reality the problem that Daniel pointed out is an open item for pg12.

I took a look at this but I don't see that Andres did anything in that
commit other than move code.  In the new code,
heapam_estimate_rel_size() does this:

+    if (curpages < 10 &&
+        relpages == 0 &&
+        !rel->rd_rel->relhassubclass)
+        curpages = 10;
+
+    /* report estimated # pages */
+    *pages = curpages;
+    /* quick exit if rel is clearly empty */
+    if (curpages == 0)
+    {
+        *tuples = 0;
+        *allvisfrac = 0;
+        return;
+    }

And here's what the code in estimate_rel_size looked like before the
commit you mention:

             if (curpages < 10 &&
                 rel->rd_rel->relpages == 0 &&
                 !rel->rd_rel->relhassubclass &&
                 rel->rd_rel->relkind != RELKIND_INDEX)
                 curpages = 10;

             /* report estimated # pages */
             *pages = curpages;
             /* quick exit if rel is clearly empty */
             if (curpages == 0)
             {
                 *tuples = 0;
                 *allvisfrac = 0;
                 break;
             }

It's all the same, except that now that the test is in heap-specific
code it no longer needs to test for RELKIND_INDEX.

I may be missing something here, but I don't know what it is.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Custom table AMs need to include heapam.h because of BulkInsertState
Следующее
От: Daniel Gustafsson
Дата:
Сообщение: Re: Ought to use heap_multi_insert() for pg_attribute/dependinsertions?