Re: 1 char in the world

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matt Mello <alien(at)spaceship(dot)com>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: 1 char in the world
Date: 2003-01-29 15:56:27
Message-ID: 26667.1043855787@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Matt Mello <alien(at)spaceship(dot)com> writes:
> Test query=
> "char"/TEXT: explain analyze select count(*) from table where bool='Y';
> boolean: explain analyze select count(*) from table where bool=true;
> Table size (see above)
> Performance averages:
> TEXT 24ms
> BOOLEAN 28ms
> "char" 17ms

I don't believe those numbers for a moment. All else being equal,
comparing a "char" field to a literal should be exactly the same speed
as comparing a bool field to a literal (and if you'd just said "where bool",
the bool field would be faster). Both ought to be markedly faster than
text.

Look for errors in your test procedure. One thing I'd particularly
wonder about is whether the query plans are the same. In the absence of
any VACUUM ANALYZE data, I'd fully expect the planner to pick a
different plan for a bool field than text/char --- because even without
ANALYZE data, it knows that a bool column has only two possible values.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message John Lange 2003-01-29 18:29:00 Re: Query plan and Inheritance. Weird behavior
Previous Message Hannu Krosing 2003-01-29 12:18:20 Re: 1 char in the world