Re: NOT LIKE much faster than LIKE?

From: Andrea Arcangeli <andrea(at)cpushare(dot)com>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-performance(at)postgresql(dot)org
Subject: Re: NOT LIKE much faster than LIKE?
Date: 2006-01-10 15:27:20
Message-ID: 20060110152720.GL15897@opteron.random
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Jan 10, 2006 at 10:11:18AM -0500, Greg Stark wrote:
>
> Andrea Arcangeli <andrea(at)cpushare(dot)com> writes:
>
> > Fixing this with proper stats would be great indeed. What would be the
> > most common value for the kernel_version? You can see samples of the
> > kernel_version here http://klive.cpushare.com/2.6.15/ . That's the
> > string that is being searched against both PREEMPT and SMP.
>
> Try something like this where attname is the column name and tablename is,
> well, the tablename:
>
> db=> select most_common_vals from pg_stats where tablename = 'region' and attname = 'province';
> most_common_vals
> ------------------
> {ON,NB,QC,BC}

Thanks for the info!

klive=> select most_common_vals from pg_stats where tablename = 'klive' and attname = 'kernel_version';
most_common_vals
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{"#1 Tue Sep 13 14:56:15 UTC 2005","#1 Fri Aug 19 11:58:59 UTC 2005","#7 SMP Fri Oct 7 15:56:41 CEST 2005","#1 SMP Fri Aug 19 11:58:59 UTC 2005","#2 Thu Sep 22 15:58:44 CEST 2005","#1 Fri Sep 23 15:32:21 GMT 2005","#1 Fri Oct 21 03:46:55 EDT 2005","#1 Sun Sep 4 13:45:32 CEST 2005","#5 PREEMPT Mon Nov 21 17:53:59 EET 2005","#1 Wed Sep 28 19:15:10 EDT 2005"}
(1 row)

klive=> select most_common_freqs from pg_stats where tablename = 'klive' and attname = 'kernel_version';
most_common_freqs
-------------------------------------------------------------------------------------------
{0.0133333,0.0116667,0.011,0.009,0.00733333,0.00666667,0.00633333,0.006,0.006,0.00566667}
(1 row)

klive=>

There's only one preempt near the end, not sure if it would work?

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2006-01-10 15:46:53 Re: NOT LIKE much faster than LIKE?
Previous Message Tom Lane 2006-01-10 15:22:59 Re: 500x speed-down: Wrong statistics!