Re: [PERFORM] Question about trigram GIST index

2014-12-18 Thread Kevin Grittner
Giuseppe Broccolo wrote: > I'm not sure about the '%' operator, but I'm sure that the GIST > index will never be used in the > > SELECT * FROM users WHERE lower(name) LIKE '%john%'; > > query; it is used for left or right anchored search, such as > 'john%' or '%john'. It *will* use a *trigram*

Re: [PERFORM] Question about trigram GIST index

2014-12-18 Thread Robert DiFalco
Jeff, I'm not seeing that limitation. On Thu, Dec 18, 2014 at 10:33 AM, Jeff Janes wrote: > > On Thu, Dec 18, 2014 at 10:00 AM, Giuseppe Broccolo < > giuseppe.brocc...@2ndquadrant.it> wrote: >> >> I'm not sure about the '%' operator, but I'm sure that the GIST index >> will never be used in the >

Re: [PERFORM] Question about trigram GIST index

2014-12-18 Thread Jeff Janes
On Thu, Dec 18, 2014 at 10:00 AM, Giuseppe Broccolo < giuseppe.brocc...@2ndquadrant.it> wrote: > > I'm not sure about the '%' operator, but I'm sure that the GIST index will > never be used in the > > SELECT * FROM users WHERE lower(name) LIKE '%john%'; > > query; it is used for left or right anc

Re: [PERFORM] Question about trigram GIST index

2014-12-18 Thread Robert DiFalco
I'm pretty sure '%John%' uses the index. explain analyze verbose SELECT name FROM wai_users WHERE lower(name) LIKE '%john%'; QUERY PLAN --

Re: [PERFORM] Question about trigram GIST index

2014-12-18 Thread Giuseppe Broccolo
I'm not sure about the '%' operator, but I'm sure that the GIST index will never be used in the SELECT * FROM users WHERE lower(name) LIKE '%john%'; query; it is used for left or right anchored search, such as 'john%' or '%john'. Giuseppe. -- Giuseppe Broccolo - 2ndQuadrant Italy PostgreSQL T

Re: [PERFORM] Question about trigram GIST index

2014-12-18 Thread Robert DiFalco
I know! I was surprised that % 'John' or % 'JOHN' or even % 'jOhn' all returned the same result. Besides readability would there be any technical differences between a GIST index that is lower or not and using LIKE vs. %? Thanks! On Thu, Dec 18, 2014 at 9:18 AM, Tom Lane wrote: > > Robert DiFa

Re: [PERFORM] Excessive memory used for INSERT

2014-12-18 Thread Alessandro Ipe
Hi, I can send a full dump of my database (< 2MB) if it is OK for you. Thanks, A. On Thursday 18 December 2014 12:05:45 Tom Lane wrote: > Alessandro Ipe writes: > > Hi, > > I tried also with an upsert function > > CREATE FUNCTION upsert_func(sql_insert text, sql_update text) RETURNS void

Re: [PERFORM] Question about trigram GIST index

2014-12-18 Thread Tom Lane
Robert DiFalco writes: > So, for my use case I simply need to search for a case insensitive > substring. It need not be super exact. It seems like there are two ways I > can do this: > CREATE INDEX idx_users_name ON users USING GIST(lower(name) gist_trgm_ops); > SELECT * FROM users WHERE lower(na

[PERFORM] Question about trigram GIST index

2014-12-18 Thread Robert DiFalco
So, for my use case I simply need to search for a case insensitive substring. It need not be super exact. It seems like there are two ways I can do this: CREATE INDEX idx_users_name ON users USING GIST(lower(name) gist_trgm_ops); SELECT * FROM users WHERE lower(name) LIKE '%john%'; Or I can do it

Re: [PERFORM] Excessive memory used for INSERT

2014-12-18 Thread Tom Lane
Alessandro Ipe writes: > Hi, > I tried also with an upsert function > CREATE FUNCTION upsert_func(sql_insert text, sql_update text) RETURNS void > LANGUAGE plpgsql > AS $$ > BEGIN > EXECUTE sql_update; > IF FOUND THEN > RETURN; > END IF; > BEGIN > EXECUTE sql_insert; > EXCE

Re: [PERFORM] Excessive memory used for INSERT

2014-12-18 Thread Alessandro Ipe
Hi, I tried also with an upsert function CREATE FUNCTION upsert_func(sql_insert text, sql_update text) RETURNS void LANGUAGE plpgsql AS $$ BEGIN EXECUTE sql_update; IF FOUND THEN RETURN; END IF; BEGIN EXECUTE sql_insert; EXCEPTION WHEN OTHERS THEN EXECUTE sql_update; END;

Re: [PERFORM] Excessive memory used for INSERT

2014-12-18 Thread Alessandro Ipe
On Thursday 18 December 2014 08:51:47 Torsten Förtsch wrote: > On 17/12/14 16:14, Alessandro Ipe wrote: > > 2014-12-15 17:54:07 GMT LOG: server process (PID 21897) was terminated > > by signal 9: Killed > > since it was killed by SIGKILL, maybe it's the kernel's OOM killer? Indeed and this hopef

Re: [PERFORM] Excessive memory used for INSERT

2014-12-18 Thread Alessandro Ipe
Hi, A grep in a nightly dump of this database did not return any AFTER trigger. The only keys are primary on each daily table, through ADD CONSTRAINT "MSG_-MM-DD_pkey" PRIMARY KEY (slot, msg); and on the global table ADD CONSTRAINT msg_pkey PRIMARY KEY (slot, msg); Regards, A. On Wedne