Re: [SQL] Rules, functions and RETURNING

2009-09-17 Thread Adrian Klaver
On Thursday 17 September 2009 8:35:52 am Nico Mandery wrote: > Hello list, > > I am trying to wirte a rule which calls a PLPgSQL-function upon an > Insert in a table. Here is a somewhat simplified example of what i got > so far: > > CREATE TABLE mytable ( > mytable_id serial PRIMARY KEY, >

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread Craig Ringer
Tom Lane wrote: > rawi writes: >> Grails/Hibernate wishes per default one sequence for all tables-PKs and all >> PKs as BigInt. > > Redesign that software; this is fundamentally broken and stupid. It's a pretty silly default, but it's clearly intended for simple / small databases. In any real da

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Frank Bax
Gavin McCullagh wrote: On Thu, 17 Sep 2009, Frank Bax wrote: Gavin McCullagh wrote: SELECT time, to_timestamp(time) AS ts, EXTRACT('months',to_timestamp(time)) FROM mdl_log; ERROR: syntax error at or near "," LINE 1: ...t time, to_timestamp(time) AS ts, extract('months',to_times... Try repl

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Gavin McCullagh
On Thu, 17 Sep 2009, Osvaldo Kussama wrote: > From manual: > http://www.postgresql.org/docs/current/interactive/functions-datetime.html > > date_part('month',to_timestamp(time)) > or > extract(month from to_timestamp(time)) Gah. I don't know I missed that. This works fine. SELECT extract(mo

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Gavin McCullagh
On Thu, 17 Sep 2009, Gavin McCullagh wrote: > On Thu, 17 Sep 2009, Frank Bax wrote: > > > Gavin McCullagh wrote: > >> SELECT time, to_timestamp(time) AS ts, > >> EXTRACT('months',to_timestamp(time)) FROM mdl_log; > >> ERROR: syntax error at or near "," > >> LINE 1: ...t time, to_timestamp(time)

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Osvaldo Kussama
2009/9/17 Gavin McCullagh : > On Thu, 17 Sep 2009, Frank Bax wrote: > >> Gavin McCullagh wrote: >>> SELECT time, to_timestamp(time) AS ts, >>> EXTRACT('months',to_timestamp(time)) FROM mdl_log; >>> ERROR:  syntax error at or near "," >>> LINE 1: ...t time, to_timestamp(time) AS ts, extract('months'

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Gavin McCullagh
On Thu, 17 Sep 2009, Frank Bax wrote: > Gavin McCullagh wrote: >> SELECT time, to_timestamp(time) AS ts, >> EXTRACT('months',to_timestamp(time)) FROM mdl_log; >> ERROR: syntax error at or near "," >> LINE 1: ...t time, to_timestamp(time) AS ts, extract('months',to_times... > > Try replacing extr

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Frank Bax
Gavin McCullagh wrote: SELECT time, to_timestamp(time) AS ts, EXTRACT('months',to_timestamp(time)) FROM mdl_log; ERROR: syntax error at or near "," LINE 1: ...t time, to_timestamp(time) AS ts, extract('months',to_times... Try replacing extract('month',value) with extract('months' from value

[SQL] extracting from epoch values in pgsql

2009-09-17 Thread Gavin McCullagh
Hi folks, I have a db that I need to draw some stats from. The db itself is from the web application moodle which, perhaps to be cross-platform, uses unix epoch times stored as integers throughout (see table description at end of mail). I'd like to query some stats based on the appearance of obje

[SQL] Rules, functions and RETURNING

2009-09-17 Thread Nico Mandery
Hello list, I am trying to wirte a rule which calls a PLPgSQL-function upon an Insert in a table. Here is a somewhat simplified example of what i got so far: CREATE TABLE mytable ( mytable_id serial PRIMARY KEY, something text ); CREATE OR REPLACE FUNCTION _rule_insert_my(someth

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread Leo Mannhart
rawi wrote: > > Leo Mannhart wrote: >> Caveat: If you use the standard sequence generator in hibernate, it is >> not using the postgres-sequence in the "usual" manner. hibernate itself >> caches 50 ID's as sequence numbers by default. This means, hibernate >> only does a select on the database seq

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread Rob Sargent
Above all, do not fret about whether or not it is "cool to lose" some ids. There are plenty of integers; the ids need not be consecutive. I don't think Grails requires a single sequence source and I know hibernate does not. Hibernate will allow one to inject any sequence/id generator you wis

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread rawi
Tom Lane-2 wrote: > >> Grails/Hibernate wishes per default one sequence for all tables-PKs and >> all >> PKs as BigInt. > > Redesign that software; this is fundamentally broken and stupid. > Hi Tom, its me again... I only need to further understand... What for a source did have the OIDs in

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread rawi
Leo Mannhart wrote: > > Caveat: If you use the standard sequence generator in hibernate, it is > not using the postgres-sequence in the "usual" manner. hibernate itself > caches 50 ID's as sequence numbers by default. This means, hibernate > only does a select on the database sequence every 50 n

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread rawi
Tom Lane-2 wrote: > >> Grails/Hibernate wishes per default one sequence for all tables-PKs and >> all >> PKs as BigInt. > > Redesign that software; this is fundamentally broken and stupid. > Thank you Tom... but redesigning Grails and Hibernate is far beyond my possibilities :) I could work

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread Tom Lane
rawi writes: > Grails/Hibernate wishes per default one sequence for all tables-PKs and all > PKs as BigInt. Redesign that software; this is fundamentally broken and stupid. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes t

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread Leo Mannhart
rawi wrote: > Hello! > > The subject says it... > > Grails/Hibernate wishes per default one sequence for all tables-PKs and all > PKs as BigInt. > > What would you think about a database with some tens of tables and > incidentally low to moderate insert concurrency spread in about the half of >

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread rawi
SORRY for incorrectly posting this here! I couldn't move it to PostgreSQL - performance... afterwards. While I don't want to double-post: It would be perfect, if the mail list admin - please - could correct my mistake... Regards, Rawi -- View this message in context: http://www.nabble.com/Hib

[SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-17 Thread rawi
Hello! The subject says it... Grails/Hibernate wishes per default one sequence for all tables-PKs and all PKs as BigInt. What would you think about a database with some tens of tables and incidentally low to moderate insert concurrency spread in about the half of the tables from at most 10 conc