Re: Query Optimisation and TEXT fields - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Query Optimisation and TEXT fields
Date
Msg-id 23816.967000826@sss.pgh.pa.us
Whole thread Raw
In response to Query Optimisation and TEXT fields  (Andrew McMillan <Andrew@catalyst.net.nz>)
List pgsql-hackers
Andrew McMillan <Andrew@catalyst.net.nz> writes:
> I am having some problems getting optimised queries when I use TEXT
> fields in records.  It seems that PostgreSQL is assuming that these
> fields are 4 bytes wide so the record width calculation is wrong and
> this means that all of the dependant calculations are wrong.

4 bytes?  I'd have expected 12 (see _DEFAULT_ATTRIBUTE_WIDTH_ as used
in src/backend/optimizer/path/costsize.c).  While this is obviously
pretty brain-dead, I have not seen many cases in which that particular
bogosity was the limiting factor in the accuracy of the optimizer's
calculations.  Usually it's the row count rather than row width that
we're hopelessly lost on :-(

At some point it might be useful for VACUUM to calculate a real
average-field-width value for varlena columns and store same in
pg_statistic.  I can't get excited about it quite yet though.
If you dig into costsize.c you'll see that the estimated row width
is just a minor factor in the estimates.  In particular, it has no
relevance whatever for seqscan-vs-indexscan choices.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Mitch Vincent"
Date:
Subject: Re: How Do You Pronounce "PostgreSQL"?
Next
From: Tom Lane
Date:
Subject: Re: Interesting new bug?