Re: [GENERAL] Optimizing a read-only database

2015-05-19 Thread hari . fuchs
François Battail writes: > My bad, got it. May be interesting but as I have a lot of indexes it > will be hard to test and to choose the best candidate. No idea of how > it can affect EWKB data indexed by a GiST (PostGIS) index, but it's > something to try just to know. You could also raise the

Re: [GENERAL] Best practices for aggregate table design

2015-10-08 Thread hari . fuchs
Thomas Kellerer writes: > droberts schrieb am 06.10.2015 um 20:53: >> Okay, so is it safe to say I should use loosely use these guidelines when >> deciding whether to model an attribute as a dimension >> (type=[inbound,outbound]) vs. bundling with a measure (total_inbound) ? >> >> If you know th

Re: [GENERAL] Aggregating over nodes in hierarchical trees

2014-09-11 Thread hari . fuchs
"McGehee, Robert" writes: > SELECT n.node, sum(students) as students > FROM tree_tbl t, node_tbl n > WHERE t.course ~ '.*' || n.node || '.*' > GROUP BY n.node; I'd write this as SELECT n.node, sum(students) AS students FROM tree_tbl t JOIN node_tbl n ON t.course ~ ('*.' || n.node || '.*')::lque

Re: [GENERAL] Converting char to varchar automatically

2014-10-06 Thread hari . fuchs
Melvin Davidson writes: > This query might work for you, but double check all result statements first. > > SELECT 'ALTER TABLE ' || quote_ident(n.nspname) || '.' || > quote_ident(c.relname) >|| ' ALTER COLUMN ' || quote_ident(a.attname) || ' TYPE varchar;' > FROM pg_class c > JOIN pg_

Re: [GENERAL] Converting char to varchar automatically

2014-10-09 Thread hari . fuchs
"Andrus" writes: > Hi! > > Thank you. > >>This revised query should give you what you need: >>SELECT 'ALTER TABLE ' || quote_ident(n.nspname) || '.' >>|| quote_ident(c.relname) >>|| ' ALTER COLUMN ' || quote_ident(a.attname) || ' TYPE varchar(' >> || i.character_maximum_l

Re: [GENERAL] Finding date intersections

2014-10-25 Thread hari . fuchs
John McKown writes: > ​I've been think about this for a bit. But I'm not getting a real solution. > I have an approach, shown below, that I think might be the bare beginnings > of an approach, but I'm just not getting any more inspiration. Perhaps it > will spark an idea for you or someone else.

Re: [GENERAL] Help with PostgreSQL 9.4 to expand jsonb int array into table with row numbers

2014-11-04 Thread hari . fuchs
David G Johnston writes: > Neil Tiffin-3 wrote >> Trying to wrap my head around postgresql 9.4 jsonb and would like some >> help figuring out how to do the following. >> >> Given the following example jsonb: >> >> ‘{“name1” : value1, “name2” : value2, “name3” : [int1, int2, int3] >> }’

Re: [GENERAL] Tree structure

2013-09-20 Thread hari . fuchs
Kaare Rasmussen writes: > Hi > > I'm trying to determine the best way to represent a simple tree > structure (like a file/dir tree or a uri path). I guess that's done a > zillion times before; I just don't seem to be able to find the right > solution. I have one special request, that I'd like to

Re: [GENERAL] Help with exclusion constraint

2014-03-28 Thread hari . fuchs
Moshe Jacobson writes: > Take the following table: > > CREATE TABLE exclusion_example AS > ( > pk_col integer primary key, > fk_col integer not null references other_table, > bool_col boolean not null > ); > > I want to ensure that for any given value of fk_col that there is a max

Re: [GENERAL] Exclusion constraints with time expressions

2012-11-06 Thread hari . fuchs
"Albe Laurenz" writes: > I think the problem is that this + operator is implemented > by the function "timestamptz_pl_interval", which is STABLE > but not IMMUTABLE. > > I am not sure why this function cannot be IMMUTABLE, it > seems to me that it should be. No: the result of e.g. SELECT TIME

Re: [GENERAL] Finding first free time from reservations table

2012-11-15 Thread hari . fuchs
"Andrus" writes: > How to find first free half hour in table which is not reserved ? > > E.q if table contains > > startdate starthour duration > 14 9 1 -- ends at 9:59 > 14 10 1.5-- ends at 11:29, e.q there is > 30 minute ga

Re: [GENERAL] Which is faster: char(14) or varchar(14)

2012-12-04 Thread hari . fuchs
Edson Richter writes: > In this specific case, the full length (14) is mandatory... so seems > there is no loss or gain. > Also, I see all varchar(...) created are by default "storage = > EXTENDED" (from "Pg Admin"), while other datatypes (like numeric, > smallint, integer) are "storage = MAIN".

Re: [GENERAL] How to get a signal from the database when a INSERT INTO is done?

2012-02-28 Thread hari . fuchs
Daniele Varrazzo writes: >> As mentioned above and as demonstrated in the example, select() also >> does the job. Using such a fancy framework is usually an overkill. > Yeah, the problem is usually if you have to do something else apart > from listening from the notification. select() will block

Re: [GENERAL] Anonymized database dumps

2012-03-19 Thread hari . fuchs
Janning Vygen writes: > pgcrypto does not work for this scenario as far as i know. > > pgcrypto enables me to encrypt my data and let only a user with the > right password (or key or whatever) decrypt it, right? So if i run it > in a test environment without this password the application is broke

Re: [GENERAL] how to group by similarity ?

2012-04-25 Thread hari . fuchs
Andreas writes: > How would I group the table so that it shows groups that have > similarity () > x ? > > Lets say the table looks like this: > > id, txt > 1, aa1 > 2, bb1 > 3, cc1 > 4, bb2 > 5, bb3 > 6, aa2 > ... > > How would a select look like that shows: > > id, txt, group_

Re: [GENERAL] how to group by similarity ?

2012-04-25 Thread hari . fuchs
Andreas writes: > How would I group the table so that it shows groups that have > similarity () > x ? > > Lets say the table looks like this: > > id, txt > 1, aa1 > 2, bb1 > 3, cc1 > 4, bb2 > 5, bb3 > 6, aa2 > ... > > How would a select look like that shows: > > id, txt, group_