postgresql-9.1

postgresql server doesn't listen

北战南征 提交于 2019-12-11 03:47:25
问题 I just recently install PostgreSQL on our server via SSH. The installation went successful, until the time I tried to connect to it using pgAdmin on my Windows machine.I received this kind of error: could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "xxx.xxx.xxx.xxx" and accepting TCP/IP connections on port 5432? xxx.xxx.xxx.xxx = my server's public IP. The docs suggest this can be fixed by setting the value of listen_addresses = '*' in the /etc

Store XML explain plan in PostgreSQL database

北慕城南 提交于 2019-12-11 02:12:24
问题 How can I store XML explain plan (or any other format) in PostgreSQL database? Test data: explain (verbose, format xml) select 1 Table to store results: create table tmp.explain_plan_data (expp xml); My naive test failed: insert into tmp.explain_plan_data values (explain (verbose, format xml) select 1); It seems that explain cannot be used in any other select statement, the following statement does not work either: select * from (explain (verbose, format xml) select 1) a We are using

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea

不问归期 提交于 2019-12-11 01:57:02
问题 I have been looking everywhere (google, stackoverflow, etc.) for some documentation on how to use the PostgreSQL pg_read_binary_file() function. The only meaningful thing I can find is this page in the official documentation. Every time I try to use this function I get an error. For example: SELECT pg_read_binary_file('/some/path/and/file.gif'); ERROR: absolute path not allowed or SELECT pg_read_binary_file('file.gif'); ERROR: could not stat file "file.gif": No such file or directory Do I

PostgreSQL Ordering Records in a Hierarchal Query Result

假装没事ソ 提交于 2019-12-11 01:48:21
问题 I am trying to do something that should be simple but I'm missing something. I am trying to return some hierarchical data in grouped and ordered. a Rather than trying to explain, I am attaching a picture... heard they are worth a thousand words: Note that hard coded values are no good because the main selection criteria will be the article_id, and then ordered along the lines of the first 'root level' article_comment_id for the article followed by its sub-nodes, then the next 'root level'

How to add Indian timezone to Postgresql?

可紊 提交于 2019-12-10 23:18:16
问题 i'm trying to find out what's the easiest way to add India Standard Time (+0530 from utc) to postgresql (9.1). i tried the silly thing of trying to insert it into the table, but it doesn't work. insert into pg_timezone_abbrevs values('INDIA','05:30:00'); the problem what detected years ago by other people, Googling in old mailing lists tells me. but not simple solution found. 回答1: Buttom line : don't use IST , that's Israel time zone, not Indian time zone. use ' Asia/Kolkata '. instead.

Crosstab splitting results due to presence of unrelated field

瘦欲@ 提交于 2019-12-10 19:43:05
问题 I'm using postgres 9.1 with tablefunc:crosstab I have a table with the following structure: CREATE TABLE marketdata.instrument_data ( dt date NOT NULL, instrument text NOT NULL, field text NOT NULL, value numeric, CONSTRAINT instrument_data_pk PRIMARY KEY (dt , instrument , field ) ) This is populated by a script that fetches data daily. So it might look like so: | dt | instrument | field | value | |------------+-------------------+-----------+-------| | 2014-05-23 | SGX.MiniJGB.2014U | PX

Postgresql 9.x: Index to optimize `xpath_exists` (XMLEXISTS) queries

孤人 提交于 2019-12-10 19:19:43
问题 We have queries of the form select sum(acol) where xpath_exists('/Root/KeyValue[Key="val"]/Value//text()', xmlcol) What index can be built to speed up the where clause ? A btree index created using create index idx_01 using btree(xpath_exists('/Root/KeyValue[Key="val"]/Value//text()', xmlcol)) does not seem to be used at all. EDIT Setting enable_seqscan to off , the query using xpath_exists is much faster (one order of magnitude) and clearly shows using the corresponding index (the btree

biginteger array functions

╄→尐↘猪︶ㄣ 提交于 2019-12-10 18:32:40
问题 Are there any available functions for work with big integers? I've found a module intarray, but functions from this module only work with integer , not bigint . I miss a function for removing an item from an array. Something like the implementation of a "minus" operator in mentioned module: int[] - int (remove entries matching right argument from array) 回答1: Updated 2015 with a better version. You can substitute your own function. This one is reasonably fast: CREATE OR REPLACE FUNCTION arr

playframework 2.0 - exceeded max_user_connections on database evolutions (with local postgres server)

为君一笑 提交于 2019-12-10 18:08:31
问题 I am having the same exact issue as (playframework 2.0 - exceeded max_user_connections on database evolutions?) only this time it is with a local postgres install. I have a sample application I threw up on hub @ http://git.io/CdEntA. I attempt to run it locally, using sbt stage target/start -DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver - Ddb.default.url="jdbc:postgresql://localhost:5432/test?user=myuser" When I launch http://localhost:9000, all I see on the console

Unable to restore pg_dump backup

雨燕双飞 提交于 2019-12-10 16:12:36
问题 I'm trying to restore backup from Postgres 9.1.1, which was created by: pg_dump mydb > backup.sql restore on Postgres 9.1.9 psql -d mydb -f backup.sql I'm getting this error: psql:datasets.sql:278537: invalid command \. psql:datasets.sql:278544: ERROR: syntax error at or near "1" LINE 1: 1 4446 49 253.412262 239.618317 0 211.54303 100.482948 197.1... The \. is part of COPY command, I guess it should be compatible between Postgres 9 versions, or it's not? COPY data_136 (id, in_1, in_2, in_3,