Re: Explain is slow with tables having many columns

From: Andres Freund <andres(at)anarazel(dot)de>
To: legrand legrand <legrand_legrand(at)hotmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Explain is slow with tables having many columns
Date: 2018-09-24 19:50:48
Message-ID: 20180924195048.7dhnjvq5ggwjtiwi@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

Hi,

(CCing -hackers)

On 2018-09-24 12:22:28 -0700, legrand legrand wrote:
> I have found that explain on tables with many (hundreds) columns
> are slow compare to nominal executions.

Yea, colname_is_unique() (called via make_colname_unique()) is
essentially O(#total_columns) and rougly called once for each column in
a select list (or using or ...). IIRC we've hit this once when I was at
citus, too.

We really should be usign a more appropriate datastructure here - very
likely a hashtable. Unfortunately such a change would likely be a bit
too much to backpatch...

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-09-24 19:51:53 Re: Explain is slow with tables having many columns
Previous Message Thomas Munro 2018-09-24 19:46:45 Re: Missing const in DSA.

Browse pgsql-performance by date

  From Date Subject
Next Message Andres Freund 2018-09-24 19:51:53 Re: Explain is slow with tables having many columns
Previous Message legrand legrand 2018-09-24 19:43:44 Re: Explain is slow with tables having many columns