Re: To prefer sorts or filters in postgres, that is the question....

2018-04-17 Thread Bob Jones
> > At a short glance, I'd say that they are pretty much the same. > The filter and the top-1-sort will both require a single scan through > the result set and one operation per row found. > And the recursive queries are pretty similar, right? > > Yours, > Laurenz Albe > -- > Cybertec |

To prefer sorts or filters in postgres, that is the question....

2018-04-16 Thread Bob Jones
Hi, I've been playing around with hierarchical queries a bit and one thing I wanted to do is build a query that gives the ultimate parent for a given child. The two queries below seem to be a good a shortlist as any. I'm no query-plan guru, but these seem to be largely identical aside from one

Re: cursor "x" does not exist

2018-04-14 Thread Bob Jones
On 14 April 2018 at 16:38, Tom Lane <t...@sss.pgh.pa.us> wrote: > Bob Jones <r.a.n.d.o.m.d.e.v.4+postg...@gmail.com> writes: >> My apologies if I'm being incredibly stupid here, but I've reviewed >> what the docs have to say about naming portals and I still can't see &g

Recursive CTE for building menus

2018-04-13 Thread Bob Jones
Hello, Whilst researching current thinking on hierarchical queries in Postgres, I stumbled accross this excellent blog post: https://illuminatedcomputing.com/posts/2014/09/postgres-cte-for-threaded-comments/ But try as I might, my SQL-foo is not up to scratch to adapt it to my needs, I keep on