postgresql

PostgreSQL - max number of parameters in "IN" clause?

This is a pretty tough question to Google, so hopefully someone can help me out here. In Postgres, you can specify an IN clause, like: SELECT * FROM user WHERE id IN (1000, 1001, 1002) Does anyone know what's the max number of parameters you can pass into IN? Thanks. ...

How to add integer column with default of unix timestamp (epoch) in PostgreSQL?

This doesn't work: create table event ( ... time int default date_part('epoch', timestamp 'now'), ... ); ...

SQL query for point-in-polygon using Postgres

I have the following simple table: CREATE TABLE tbl_test ( id serial NOT NULL, poly polygon NOT NULL ) WITH (OIDS=FALSE); I then try to insert a row with a polygon: insert into tbl_test values(1, PolyFromText('POLYGON((0 0, 10 10, 10 0, 0 0))')) And run into this error: column "poly" is of type polygon but expression is of ...

How to store datetime in database if time portion is optional?

Should I store it in a single timestamp/datetime field or separate date and time fields? I prefer to store it as a single timestamp field but I need to know when a user didn't enter a time portion. How to best store this in the database? I'm using postgresql. Thanks. ...

PostgreSQL - how to run VACUUM from code outside transaction block?

I am using Python with psycopg2 and I'm trying to run a full VACUUM after a daily operation which inserts several thousand rows. The problem is that when I try to run the VACUUM command within my code I get the following error: psycopg2.InternalError: VACUUM cannot run inside a transaction block How do I run this from the code outsid...

Is it possible to use a database link between an oracle database and a postgresql database on different physical servers

I've trying to streamline an intranet application where some of the data is stored locally on the postgresql database of the intranet server and other related data is stored in our enterprise oracle 10g2r2 database. What I would like to do is create a view on either database box wouldn't really matter that combines for simplicity sake...

Spatial Data in PostgreSQL

PostgreSQL supports a variety of geometric types out of the box, along with lots of geometric operators and GiST indexes which seem to offer spatial indexing of data. And then there's also PostGIS, which is an extension to PG. What is the difference between the built-in spatial support in PG and PostGIS? If my application needs to sto...

Postgresql: using 'NULL' value when insert and update rows with prepared statements

Hi guys, sometimes i need to insert into the table some null values, or update them setting the value to NULL. I've read somewhere in the postgresql documentation that this cant be done, but can be tricket with the default value: pg_query("INSERT INTO my_table (col_a, col_b) VALUES ('whatever', default) p.s: i know that in this examp...

How to install and setup PgQ?

I wanna try to use PgQ, but can't find any documentaion how to install it on my database. Do I need to install some stored procedures or something like that? ...

Using django_extensions reset_db command with postgres

I'm having some trouble getting the reset_db command extension to work with my postgres database. I get an error "psycopg2.OperationalError: cannot drop the currently open database" which looks like the same issue reported here. I'm using django 1.0 and django_extensions 0.4.1, which I believe has the fix for the above issue included. S...

Postgresql: Update timestamp when row is updated

In Mysql, we can execute this where it updates the changetimestamp every time the row is changed. create table ab (id int, changeTimestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP ); Is there something similar to do the above in Postgresql? ...

How much more performant is Postgres than MYSQL on fulltext search?

I've been a MYSQL user,never tried Postgres . But MYSQL has bottle neck on fulltext search when the data set is huge. ...

Slony-I replication CPU usage

Hi, I have recently had to install slony (version 2.0.2) at work. Everything works fine, however, my boss would like to lower the cpu usage on slave nodes during replication. Searching on the net does not reveal any blatantly obvious answers to this. Any suggestions that would help reduce CPU usage (or spread the update out over a longe...

Oracle Generic DB Link not working

I'm trying to use oracle's hsodbc generic database link driver to access a postgresql database from my oracle 10gr2 database server. I think I have everything configured but I'm receiving this error from the sqlplus promt after trying a remote query. SQL> select * from temp_user@intranet; select * from temp_user@intranet ...

How do we do horizontal sharding/partitioning in Postgresql using pgpool-II?

Grid sql and pgpool-ii are partitioning tools for postgresql. gridsql is designed for reporting business applications. PGPool-II for transactional systems. Can some one show me how to do a horizontal partition on the bigint column uid on table users? thanks ...

can someone show how to setup pgpool 2 in parallel *query* mode ie horizontal partitioning

i did read both extensively, but finishing all the steps parallel mode or horizontal partitioning mode doesnot work! but this is my conf file backend_hostname, backend_port, backend_weight here are examples backend_hostname0 = 'localhost' backend_port0 = 5432 backend_weight0 = 1 backend_data_directory0 = '/mnt/work/database' backend...

How to insert Japanese text into a Postgres table using PHP?

Hi, i am tring to add "翻訳するテキストやWebページ " into a PostgreSQL table, but its shown like this: "& #32763;""& #35379;"&#12377;& #12427;&#12486;& #12461;& #12473;& #12488;& #12420;Web& #12506;& #12540;& #12472; How can I insert that in proper format? <?php $db = pg_connect("host=localhost port=5432 dbname=lang user=password=") or die(":(")...

psycopg2 on OSX: do I have to install PostgreSQL too?

Hello, I want to access a postgreSQL database that's running on a remote machine, from Python in OS/X. Do I have to install postgres on the mac as well? Or will psycopg2 work on its own. Any hints for a good installation guide for psycopg2 for os/x? ...

How to prevent primary serial primary key from being updated with number not in sequence?

CREATE TABLE u_account ( Jid serial primary key, score int4 ); The primary key works fine (updates itself) ok when I update it like this; INSERT INTO u_account ('score') VALUES ('122233344'); However when I insert a value like this; INSERT INTO u_account VALUES ('122233344'); This updates the primary key; I don't want the primar...

PostgreSQL: Why can I connect to a user with a set password without having to give the password?

After creating a new user john with: CREATE USER john PASSWORD 'test'; CREATE DATABASE johndb OWNER john; I can connect to the PostgreSQL server with: psql -U john johndb The problem is that psql never asks me for the password. I realy need to know what's wrong, because of obvious reasons. ...