You are currently browsing the archives for the Postgres category.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Mar | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 | ||||
Archive for the Postgres Category
Selecting random rows from a table
2009-03-08 by Andrew.
The question of how to select some random items from a table is one that comes up fairly often in the IRC channel (and as the subject of blog posts, such as this one from depesz).
While there is a simple solution of this form (let’s assume for now that we want to select 5 uniformly random rows from table “items”):
select * from items order by random() limit 5;
this is unfortunately slow if the table has more than a small number of rows. It is possible to do far better, though there aren’t really any perfect solutions that don’t resort to procedural logic in some way. Let’s start by looking at how to do better in plain SQL.
Read the rest of this entry »
Posted in PlanetPG, Postgres | 10 Comments »
Reading XML files into the database
2009-02-05 by Andrew.
This came up as a question on IRC: how to read an XML file on the server into a table column?
Posted in PlanetPG, Postgres | 4 Comments »
UUID generation for PostgreSQL 8.3 on FreeBSD
2008-12-21 by Andrew.
A couple of weeks ago I whomped up a quick module in response to someone on IRC who was unable to get contrib/uuid-ossp working on FreeBSD (which turns out to be due to a nasty conflict between misc/ossp-uuid and libc).
I’ve now put it up on PGFoundry, and the initial release can be found here:
http://pgfoundry.org/projects/uuid-freebsd/
Posted in PlanetPG, Postgres | 1 Comment »