Re: limit table to one row - Mailing list pgsql-general

From Brandon Metcalf
Subject Re: limit table to one row
Date
Msg-id Pine.LNX.4.58L.0906091042420.11099@cedar.geronimoalloys.com
Whole thread Raw
In response to Re: limit table to one row  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
List pgsql-general
g == gryzman@gmail.com writes:

 g> If you want to store period of time, why store it as varchar ?

 g> just store two rows
 g> create table foo(
 g>   n varchar,
 g>   val date
 g> );

 g> and store two rows:
 g> "start", now(),
 g> "end", now()+'something '::interval

 g> Wouldn't that do, or is there something I misunderstand ?

Sure, that would work, but I'm having to retrofit this table to an
existing system.  Much of the system I'm redesigning, but this piece
isn't too terribly important right now.

 g> The approach with vertical structure, is used when people want to
 g> store some particular state, say - kind of like structure in C, but in
 g> SQL, and they create table for it with all the columns, etc, and have
 g> to limit it to one row.

 g> On the other hand, you could also use unique index on (1) approach
 g> (say if you need more variety of types).

Got it.

--
Brandon

pgsql-general by date:

Previous
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: limit table to one row
Next
From: Dimitri Fontaine
Date:
Subject: Re: postgres getting slow under heavy load though autivacuum is enabled