postgresql

How to set the transaction isolation level of a

How do I set the global transaction isolation level for a postgres data source. I'm running on jboss and I'm using hibernate to connect. I know that I can set the isolation level from hibernate, does this work for Postgres? This would be by setting the hibernate.connection.isolation hibernate property to 1,2,4,8 - the various values o...

Exploring search options for PHP

I have innoDB table using numerous foreign keys, but we just want to look up some basic info out of it. I've done some research but still lost. How can I tell if my host has Sphinx installed already? I don't see it as an option for table storage method (i.e. innodb, myisam). Zend_Search_Lucene, responsive enough for AJAX function...

Dynamic upsert in postgresql

I have this upsert function that allows me to modify the fill_rate column of a row. CREATE FUNCTION upsert_fillrate_alarming(integer, boolean) RETURNS VOID AS ' DECLARE num ALIAS FOR $1; dat ALIAS FOR $2; BEGIN LOOP -- First try to update. UPDATE alarming SET fill_rate = dat WHERE equipid = num; IF FOUND TH...

Python + PostgreSQL + strange ascii = UTF8 encoding error

I have ascii strings which contain the character "\x80" to represent the euro symbol: >>> print "\x80" € When inserting string data containing this character into my database, I get: psycopg2.DataError: invalid byte sequence for encoding "UTF8": 0x80 HINT: This error can also happen if the byte sequence does not match the encodi ng ...

bytea type & nulls, Postgres

I'm using a bytea type in PostgreSQL, which, to my understanding, contains just a series of bytes. However, I can't get it to play well with nulls. For example: =# select length(E'aa\x00aa'::bytea); length -------- 2 (1 row) I was expecting 5. Also: =# select md5(E'aa\x00aa'::bytea); md5 ------------------------...

How to translate this 2 queries from Mysql to Postgresql? :

How can I translate this 2 queries in postgresql ? : CREATE TABLE `example` ( `id` int(10) unsigned NOT NULL auto_increment, `from` varchar(255) NOT NULL default '0', `message` text NOT NULL, `lastactivity` timestamp NULL default '0000-00-00 00:00:00', `read` int(10) unsigned NOT NULL, PRIMARY KEY (`id...

Default tablespace for indexes in postgres

Just wondering if its possible to set a default tablespace in postgres to keep indexes. Would like the databases to live on the default tablespace for postgres, however, would like to get the indexes on a different set of disks just to keep the i/o traffic separated. It does not appear to me that it can be done without going in and doi...

From Now() to Current_timestamp in Postgresql

In mysql I am able to do this: SELECT * FROM table WHERE auth_user.lastactivity > NOW() - 100 now in postgresql I am using this query: SELECT * FROM table WHERE auth_user.lastactivity > CURRENT_TIMESTAMP - 100 but I get this error: operator does not exist: timestamp with time zone - integer How can I resolve ? ...

How to realize this in Transact SQL ( SQL Server 2008 )

I just want an update trigger like this postgresql version... It seems to me there is no NEW. and OLD. in MSSQL? CREATE OR REPLACE FUNCTION "public"."ts_create" () RETURNS trigger AS DECLARE BEGIN NEW.ctime := now(); RETURN NEW; END; Googled already, but nothing to be found unfortunately... Ideas? Update: Sth, like this? CREATE ...

Equivalent of mysql_insert_id() for Postgresql ?

Possible Duplicate: mysql_insert_id alternative for postgresql Is there a Postgresql equivalent of mysql_insert_id() to get the ID generated in the last query ?? ...

Getting float values out of PostgreSQL

I am having trouble retrieving float/real values out of PostgreSQL. For example, I would like to store: 123456789123456, the retrieve that exact same number with a select statement. table tbl (num real) insert into tbl(num) values('123456789123456'); As it is now, if I "select num from tbl" the result is "1.23457e+14" If I run "select...

Why is this postgresql query so slow?

I'm no database expert, but I have enough knowledge to get myself into trouble, as is the case here. This query SELECT DISTINCT p.* FROM points p, areas a, contacts c WHERE ( p.latitude > 43.6511659465 AND p.latitude < 43.6711659465 AND p.longitude > -79.4677941889 AND p.longitude < -79.4477941889) ...

Why does PostgreSQL have to be different (scheme does not exist)?

I'm not used to working with PostgreSQL, but am using Zend_Db_Select to create my queries. What does the error below mean? SQL error: ERROR: schema "il" does not exist In statement: SELECT il.count(*) AS "count" FROM "image_lite" AS "il" INNER JOIN "exif_parse" AS "ex" ON il.image_id = ex.image_id WHERE (ex.cam_make = 'apple') ...

Aggregating a list of dates to start and end date

I have a list of dates and IDs, and I would like to roll them up into periods of consucitutive dates, within each ID. For a table with the columns "testid" and "pulldate" in a table called "data": | A79 | 2010-06-02 | | A79 | 2010-06-03 | | A79 | 2010-06-04 | | B72 | 2010-04-22 | | B72 | 2010-06-03 | | B72 | 2010-06-04 | | C94 | 2010-0...

Postgres 8.1 pg_trgm plugin doesn’t work with unicode chars

Is it possible to get the pg_trgm plugin in postgres server 8.1 to work with unicode chars? ...

Are mysql_close and pg_close required ?

Possible Duplicate: using mysql_close() Are mysql_close and pg_close required ? In some script there aren't... why ? What happen if I don't use its ? ...

What does it mean: SQL state: 42703 Context: Error occurred on dblink connection named "unnamed": could not execute query.

I tried to create exactly the same but new table from old table in another database using dblink. This procedure used to worked last two times, but this time I got message: "SQL state: 42703 Context: Error occurred on dblink connection named "unnamed": could not execute query." Anyone knows where is the problem or how to solve it? Pleas...

PostgreSQL and Amazon EBS Snapshots?

I found this article explaining how to run MySQL on Amazon EC2. It talks about using XFS as the filesystem and then leveraging EBS snapshots to create backups of the data. Does anyone know if I can do something similar using PostgreSQL? Are there changes to the SQL commands to FLUSH and LOCK the tables? Thanks! ...

Switch role after connecting to database

Is it possible to change the postgresql role a user is using when interacting with postgres after the initial connection? The database(s) will be used in a web application and I'd like to employ database level rules on tables and schemas with connection pooling. From reading the postgresql documentation it appears I can switch roles if ...

Any way to make this PostgreSQL count query any faster?

I'm running a case-insensitive search on a table with 7.2 million rows, and I was wondering if there was any way to make this query any faster? Currently, it takes approx 11.6 seconds to execute, with just one search parameter, and I'm worried that as soon as I add more than one, this query will become massively slow. SELECT count(*) ...