Re: [PERFORM] View containing a recursive function

2016-02-05 Thread Mathieu De Zutter
On Mon, 1 Feb 2016 at 10:45 Tom Lane wrote: > Mathieu De Zutter writes: > Assuming you have a reasonably late-model PG, you could rewrite the > view with a lateral function call: > > CREATE OR REPLACE VIEW covering_works_r AS > SELECT > w.idA

[PERFORM] View containing a recursive function

2016-01-31 Thread Mathieu De Zutter
Hi all, I have a recursive part in my database logic that I want to isolate and reuse as a view. I had found a blog that explained how move a function parameter into a view. The SQL is in attachment. When I write a query based on that view with a fixed value (or values) for the (input) parameter,

[PERFORM] Query plan change with multiple elements in IN clause

2013-08-30 Thread Mathieu De Zutter
Hi all, I'm migrating a web application to an ORM framework (Doctrine) so I need a new way to get statistics about entities into the application without importing all data, only the results (e.g. load total number of children instead of loading all children into the application and counting it aft

[PERFORM] pg_trgm and slow bitmap index scan plan

2012-08-28 Thread Mathieu De Zutter
Hi all, I've been trying to apply pg_tgrm for the search-function of my application. The database fits a few times in the available RAM, and is mostly read-only. Plans, schema and configs in attachment. Postgresql version 9.1.4 on Debian. When just searching in one table, it behaves perfectly her

Re: [PERFORM] NULLS LAST performance

2011-02-24 Thread Mathieu De Zutter
On Wed, Feb 23, 2011 at 10:37 PM, Tom Lane wrote: > Merlin Moncure writes: > > you can always do this: > > > create index performance_creation_date_desc_idx on > > performance(creation_date desc nulls last); > > > which will index optimize your sql. Interesting that 'null last' > > fools disall

[PERFORM] NULLS LAST performance

2011-02-23 Thread Mathieu De Zutter
Hi all, Running PostgreSQL 8.4.7 (backport package from Debian Lenny). I have some queries that are based on views, and an engine adds a few clauses (like NULLS LAST). One of these queries has a performance problem. The simplified form is this: shs=# explain analyze select * from performance e

Re: [PERFORM] Slow query to get last created row using CURRVAL

2010-12-04 Thread Mathieu De Zutter
On Sat, Dec 4, 2010 at 1:35 PM, Marti Raudsepp wrote: > On Sat, Dec 4, 2010 at 13:56, Mathieu De Zutter wrote: >> I have no idea why in some cases the index scan is not considered. >> Does anyone have an idea? > > I guess that it's because the currval() function is vola

[PERFORM] Slow query to get last created row using CURRVAL

2010-12-04 Thread Mathieu De Zutter
Hi all, I have a table that stores all the page loads in my web application: shs-dev=# \d log_event Table "public.log_event" Column | Type | Modifiers -+--+-

Re: [PERFORM] Slow Query- Simple taking

2010-10-19 Thread Mathieu De Zutter
On Tue, Oct 19, 2010 at 8:21 PM, Ozer, Pam wrote: > I have the following query running on 8.4, which takes 3516 ms.  It is very > straight forward.  It brings back 116412 records.  The explain only takes > 1348ms > "Sort  (cost=104491.48..105656.24 rows=116476 width=41) (actual > time=1288.413..1

Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-11 Thread Mathieu De Zutter
On Mon, Jan 11, 2010 at 3:52 AM, Robert Haas wrote: > On Sun, Jan 10, 2010 at 10:53 AM, Kevin Grittner > wrote: > > seq_page_cost = 0.1 > > random_page_cost = 0.1 > > These might not even be low enough. The reason why bitmap index scans > win over plain index scans, in general, is because you m

Re: [PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Mathieu De Zutter
On Sun, Jan 10, 2010 at 4:18 PM, Kevin Grittner wrote: > Mathieu De Zutter wrote: > > You didn't include any information on your hardware and OS, which can > be very important. Also, what version of PostgreSQL is this? > SELECT version(); output would be good. > Int

[PERFORM] Choice of bitmap scan over index scan

2010-01-10 Thread Mathieu De Zutter
Hi, Part of a larger problem, I'm trying to optimize a rather simple query which is basically: SELECT * FROM table WHERE indexed_column > ... ORDER BY indexed_column DESC; (see attachment for all details: table definition, query, query plans) For small ranges it will choose an index scan which i

Re: [PERFORM] UNION ALL and sequential scans

2009-05-14 Thread Mathieu De Zutter
On Thu, May 14, 2009 at 4:52 PM, Tom Lane wrote: > "Brad Jorsch" writes: >>  But if I add a constant-valued column to indicate which branch of the >>  union each result came from: > >>  explain analyze select * from baz join ( >>  select id, val, 'foo'::text as source from foo >>  union all >>  s

Re: [PERFORM] Sorting a query on a view ignores an index

2003-08-21 Thread Mathieu De Zutter
On Thu, Aug 21, 2003 at 01:02:08PM -0400, Tom Lane wrote: > Mathieu De Zutter <[EMAIL PROTECTED]> writes: > > Apart from avoiding views or subselects when sorting afterwards and > > putting the whole bunch in a huge SQL statement (which i'll have to > > produce o

Re: [PERFORM] Sorting a query on a view ignores an index

2003-08-21 Thread Mathieu De Zutter
On Thu, Aug 21, 2003 at 10:59:11AM -0400, Tom Lane wrote: > Mathieu De Zutter <[EMAIL PROTECTED]> writes: > > However, i dont want the view to be presorted, but sort it in the > > queries that use the view. When I do that, the index I have on that > > field seems to be i

[PERFORM] A better look on the same problem (ignored index)

2003-08-21 Thread Mathieu De Zutter
Hi, After my first mail, I found a better testcase (well it's a about the same, but you have a better look to compare). See attachment prob-query.sql The ORDER BY in the FROM clause uses the index. The last ORDER BY does not use the index. They should be the same... The query plans are identica

[PERFORM] Sorting a query on a view ignores an index

2003-08-21 Thread Mathieu De Zutter
Hi, I'm having a performance problem in postgresql. I have a rather complex view (attached) which, on itself, executes very fast, as it should. Normally this view is unordered. When I order the view itself (see comments in attachment), the view executes with about the same speed since the field i