Re: [GENERAL] 9.1: Slow to add range check on indexed column

2013-05-25 Thread Raymond O'Donnell
On 25/05/2013 20:37, Moshe Jacobson wrote: > I just created a new partition in a log table, and then built a check > constraint on the recorded timestamp column. > > I have an index on this column, but the adding of the check constraint > took a very, very long time. > > It seems that PostgreSQL

[GENERAL] 9.1: Slow to add range check on indexed column

2013-05-25 Thread Moshe Jacobson
I just created a new partition in a log table, and then built a check constraint on the recorded timestamp column. I have an index on this column, but the adding of the check constraint took a very, very long time. It seems that PostgreSQL 9.1 does not check the index when building a check constr

Re: [GENERAL] Random numbers

2013-05-25 Thread Szymon Guz
On 25 May 2013 18:14, Karel Riveron Escobar wrote: > How would be if I would want to generate values among 3 and 5? > > > Hi Karel, try something like: SELECT floor(3 + random()*(5-3+1))::INT Or generally: CREATE OR REPLACE FUNCTION random_range(INTEGER, INTEGER) RETURNS INTEGER AS $$ SELEC

Re: [GENERAL] Random numbers

2013-05-25 Thread Karel Riveron Escobar
How would be if I would want to generate values among 3 and 5? Regards, Karel Riverón Student Scientific Council Informatics Science University - Original Message - | From: "Szymon Guz" | To: "Ian Lawrence Barwick" | Cc: "bricklen" , "Karel Riveron Escobar" | , pgsql-general@postgresql.

Re: [GENERAL] Random numbers

2013-05-25 Thread Szymon Guz
On 25 May 2013 17:56, Ian Lawrence Barwick wrote: > 2013/5/26 bricklen : > > > > On Sat, May 25, 2013 at 8:45 AM, Karel Riveron Escobar > > wrote: > >> > >> I want to generate random numbers in Pl/pgSQL. How can I do this? > >> To be more specific, I have to generate random numbers among 0 and 5

Re: [GENERAL] Random numbers

2013-05-25 Thread Karel Riveron Escobar
Thanks bricklen. I found another way in PostgreSQL 9.1.0 Documentation. SELECT * INTO random_number FROM random(); -- random function gives me a random value among 0.0 -- and 1.0 SELECT * INTO rounded_number FROM round(random_number * 5); -- this line is completly obviously. Saludos, Karel Ri

Re: [GENERAL] Random numbers

2013-05-25 Thread Ian Lawrence Barwick
2013/5/26 bricklen : > > On Sat, May 25, 2013 at 8:45 AM, Karel Riveron Escobar > wrote: >> >> I want to generate random numbers in Pl/pgSQL. How can I do this? >> To be more specific, I have to generate random numbers among 0 and 5. > > > One way: > select n from unnest(ARRAY[0,1,2,3,4,5]) n orde

Re: [GENERAL] Random numbers

2013-05-25 Thread bricklen
On Sat, May 25, 2013 at 8:45 AM, Karel Riveron Escobar < kesco...@estudiantes.uci.cu> wrote: > I want to generate random numbers in Pl/pgSQL. How can I do this? > To be more specific, I have to generate random numbers among 0 and 5. > One way: select n from unnest(ARRAY[0,1,2,3,4,5]) n order by r

[GENERAL] Random numbers

2013-05-25 Thread Karel Riveron Escobar
Hello list, I want to generate random numbers in Pl/pgSQL. How can I do this? To be more specific, I have to generate random numbers among 0 and 5. Thanks in advance. Regards, Karel Riverón Student Scientific Council Informatics Science University http://www.uci.cu