Re: [GENERAL] Support functions for GiST index on citext

2014-08-18 Thread Chris Hanks
On Sat, Aug 16, 2014 at 7:02 PM, Chris Hanks wrote: > Thanks, I have considered it, and I'd like to stick with an array for > my use case if possible. Also, if citext is being advised against, I'd > like to know about it, since I use it extensively and have never had >

Re: [GENERAL] Support functions for GiST index on citext

2014-08-16 Thread Chris Hanks
ack into the array form by doing a > JOIN and grouping by the first table's primary key. > > > On Fri, Aug 15, 2014 at 11:46 AM, Chris Hanks > wrote: >> >> Hi - >> >> I have a table with a citext[] column, and I'm trying to write a >> uniqueness

[GENERAL] Support functions for GiST index on citext

2014-08-15 Thread Chris Hanks
Hi - I have a table with a citext[] column, and I'm trying to write a uniqueness constraint for the array values. That is, two rows with {one,two} and {two,three} would conflict. Since it's citext, also {one,two} and {TWO, THREE} should conflict too. My first thought was to make a unique index us

Re: [GENERAL] Joining on a view containing a UNION ALL produces a suboptimal plan on 9.3.4

2014-07-10 Thread Chris Hanks
That did the trick! Thanks, Tom! On Thu, Jul 10, 2014 at 8:47 AM, Tom Lane wrote: > Chris Hanks writes: >> CREATE VIEW tables AS >> SELECT a.*, b.col AS other_col >> FROM a >> LEFT JOIN b ON a.id = b.id >> UNION ALL >> SELECT c.*, d.col AS ot

Re: [GENERAL] Joining on a view containing a UNION ALL produces a suboptimal plan on 9.3.4

2014-07-10 Thread Chris Hanks
I need it the way it is. It's a foreign key in the actual query. Thanks! On Thu, Jul 10, 2014 at 8:31 AM, Igor Neyman wrote: >> -Original Message- >> From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- >> ow...@postgresql.org] On Behalf Of Chris Hanks

[GENERAL] Joining on a view containing a UNION ALL produces a suboptimal plan on 9.3.4

2014-07-10 Thread Chris Hanks
Hi everyone - I have a slow query issue in an app I'm working on. I'm unfortunately not at liberty to share the query/schema details, but I've put together a very similar reproduction of the issue: - CREATE TABLE a (id integer primary key, col integer); CREATE TABLE b (id integer primary key

Re: [GENERAL] row_to_json on a subset of columns.

2014-05-30 Thread Chris Hanks
That works! Thanks! On Fri, May 30, 2014 at 11:59 AM, Merlin Moncure wrote: > On Fri, May 30, 2014 at 11:16 AM, Chris Hanks > wrote: >> I'm using a JSON column to store some aggregate data, like so: >> >> UPDATE courses_table >> SET aggr

[GENERAL] row_to_json on a subset of columns.

2014-05-30 Thread Chris Hanks
I'm using a JSON column to store some aggregate data, like so: UPDATE courses_table SET aggregates = agg.aggregates FROM ( SELECT course_id, row_to_json(sub) AS aggregates FROM ( SELECT course_id, avg(rating) AS rating, sum(reviews_count) AS reviews_count,

Re: [GENERAL] Poor performance when using a window function in a view

2013-03-01 Thread Chris Hanks
On Fri, Mar 1, 2013 at 6:37 AM, Merlin Moncure wrote: > On Fri, Mar 1, 2013 at 3:59 AM, Chris Hanks > wrote: > > On Fri, Mar 1, 2013 at 1:21 AM, Raymond O'Donnell wrote: > >> > >> On 01/03/2013 00:19, Chris Hanks wrote: > >> > On Thu, Fe

Re: [GENERAL] Poor performance when using a window function in a view

2013-03-01 Thread Chris Hanks
On Fri, Mar 1, 2013 at 1:21 AM, Raymond O'Donnell wrote: > On 01/03/2013 00:19, Chris Hanks wrote: > > On Thu, Feb 28, 2013 at 6:00 AM, Tom Lane > <mailto:t...@sss.pgh.pa.us>> wrote: > > > > Chris Hanks > <mailto:christopher.m.ha...@gmail.co

Re: [GENERAL] Poor performance when using a window function in a view

2013-02-28 Thread Chris Hanks
On Thu, Feb 28, 2013 at 6:00 AM, Tom Lane wrote: > Chris Hanks writes: > > create or replace view values_view as > > select fkey1, fkey3, > > (derived1 / max(derived1) over (partition by fkey1)) as derived1, > > (derived2 / sum(derived1) over (partition by f

Re: [GENERAL] Poor performance when using a window function in a view

2013-02-28 Thread Chris Hanks
On Wed, Feb 27, 2013 at 10:18 PM, Merlin Moncure wrote: > On Wed, Feb 27, 2013 at 8:22 PM, Chris Hanks > wrote: > > Hi. Sorry if this is repetitive, I tried posting to pgsql-performance > first > > but I think it got stuck in moderation. > > > > I'm tryi

[GENERAL] Poor performance when using a window function in a view

2013-02-27 Thread Chris Hanks
Hi. Sorry if this is repetitive, I tried posting to pgsql-performance first but I think it got stuck in moderation. I'm trying to create a view that uses a window function, but it seems that Postgres is unable to optimize it. Here's a reproduction of my situation with 9.2.2: --- drop table if ex

Re: [GENERAL] Retrieving multiple columns from a subquery

2012-05-14 Thread Chris Hanks
On Mon, May 14, 2012 at 8:36 PM, Tom Lane wrote: > Chris Hanks writes: > > Nothing? Are subqueries just not meant to be used this way? > > The SQL standard says not ;-). > > You could approximate it like this: > >select ..., (select row(x,y,z) from ...), ... f

Re: [GENERAL] Retrieving multiple columns from a subquery

2012-05-14 Thread Chris Hanks
Nothing? Are subqueries just not meant to be used this way? On Wed, May 9, 2012 at 9:42 AM, Chris Hanks wrote: > Hello - > > I have two tables: > > CREATE TABLE users > ( > id serial NOT NULL, > created_at timestamp with time zone NOT NULL, > last_seen_at timest

[GENERAL] Retrieving multiple columns from a subquery

2012-05-09 Thread Chris Hanks
Hello - I have two tables: CREATE TABLE users ( id serial NOT NULL, created_at timestamp with time zone NOT NULL, last_seen_at timestamp with time zone NOT NULL, -- some other columns... ) CREATE TABLE emails ( user_id integer NOT NULL, address text NOT NULL, created_at timestamp w

Re: [GENERAL] Collapsing multiple subqueries into one

2011-08-23 Thread Chris Hanks
Ausburn wrote: > This might help you: > > http://www.postgresql.org/docs/8.4/static/queries-with.html > > On 24/08/2011, at 9:54 AM, Chris Hanks wrote: > >> I have two tables: >> >> CREATE TABLE items >> ( >>  root_id integer NOT NULL, >>  id

[GENERAL] Collapsing multiple subqueries into one

2011-08-23 Thread Chris Hanks
I have two tables: CREATE TABLE items ( root_id integer NOT NULL, id serial NOT NULL, -- Other fields... CONSTRAINT items_pkey PRIMARY KEY (root_id, id) ) CREATE TABLE votes ( root_id integer NOT NULL, item_id integer NOT NULL, user_id integer NOT NULL, type smallint NOT NULL,