postgresql-9.3

How to join several unrelated tables

爱⌒轻易说出口 提交于 2019-12-11 09:43:07
问题 I have five queries and each of them will return me single column multiple row output. I want to to write a function which will contain all of these queries. Can anyone help? query 1: Select Col1 as X from Table1; query 2: Select Col3 as Y from Table2; From a function I want to get a table which will have columns X, Y How to club these queries under single function? 回答1: Add a ROW_NUMBER() to each of the queries and join them by the row number. Depending on number of rows returned by each of

Postgis Error when upgrading to Rails 4

给你一囗甜甜゛ 提交于 2019-12-11 09:19:17
问题 My team and I are going through a maintenance phase currently, and I've been busy upgrading everything. Last week I moved the team from PostgreSQL 9.1 to 9.3 and PostGIS 1.5 to 2.1 which all went smoothly. Yesterday, the Rails team submitted a Rails 4 upgrade pull request that our CI swiftly rejected. Any suggestions would be greatly appreciated. When attempting to create a new test database, I receive the following Rails error: PG::RaiseException: ERROR: PostGIS is already installed in

Benchmarking many PostgreSQL queries

六月ゝ 毕业季﹏ 提交于 2019-12-11 08:03:50
问题 On a complex webpage more than hundred queries are executed. I search for a way to benchmark these queries. I tried to embed EXPLAIN ANALYZE into a query resp. into a psql function, to pick the execution time of every query and compare them. But EXPLAIN ANALYZE seems not to be embeddable in any way. Is there another solution to compare the execution time of some queries? Thanks a lot 回答1: There is no problem with embedding EXPLAIN in PL/pgSQL: CREATE OR REPLACE FUNCTION profile( IN query text

Error connecting to PGSQL database in Joomla

旧时模样 提交于 2019-12-11 05:34:08
问题 I am trying to install Joomla using Postgres and in the installer I have the following error: Could not connect to the database. Connector returned number: Error connecting to PGSQL database. This isn't telling me very much. Any ideas? 回答1: Unfortunately the installer does not return the real error. Here are some general tips: make sure the provided database already exists check if your database needs some specific settings, such as a different port or sslmode=require Put your connection

Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException

对着背影说爱祢 提交于 2019-12-11 05:22:18
问题 I configured hibernate to use Posgresql <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL92Dialect</property> <property name="hibernate.connection.driver_class">org.postgresql.Driver</property> But I get exception when I start tomcat: 23-Jul-2017 21:22:25.544 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 7529 ms 23-Jul-2017 21:26:47.901 INFO [http-nio-8081-exec-9] org.hibernate.Version.logVersion HHH000412: Hibernate Core {5.2.10.Final} 23-Jul-2017

real-time sync between local Postgres instance and Azure Cloud Postgres instance

守給你的承諾、 提交于 2019-12-11 04:47:10
问题 I need to set up real time sync process between a on premise postgresql instance with cloud postgresql instance. Please let me know what are all the options available through which i can achieve it. Do i have to use any specific tool or it can be managed through replication . Please advice 回答1: Use PgPool http://www.pgpool.net/mediawiki/index.php/Main_Page from their web page: pgpool-II can manage multiple PostgreSQL servers. Using the replication function enables creating a realtime backup

Is there any way to cast postgresql 9.3 data type so that it can affect only one side [duplicate]

与世无争的帅哥 提交于 2019-12-11 04:09:26
问题 This question already has answers here : Is there any technique to do in postgresql 9.3 so that it start returning 1 and 0 instead of “t” and “f” for boolean type (2 answers) Closed 5 years ago . I am using ppas9.3(oracle compatible) and i want to do the casting so that it affect at one side only. what i want is, I want a data type which can accept both integer and boolean values during insertion and comparison but didn't get any success and the main problem that is occurring is: Initially

Delete duplicates in postgres

不想你离开。 提交于 2019-12-11 03:25:57
问题 I want to delete all but one row for a given duplicate "external_id". The query below takes about two minutes to run for my table of 5,000,000 rows, and I feel like there's got to be a quicker way of performing this task. "id" is the primary key, and "external_id" is a btree indexed column: delete from posts p1 using (select distinct on (1) external_id, id from posts order by 1 desc, 2 desc) p_recent where p1.external_id = p_recent.external_id and p1.id != p_recent.id; How can I improve the

Why postgresql does not use index in this query

邮差的信 提交于 2019-12-11 03:07:18
问题 Here is the complete table definition: CREATE TABLE search.tablename ( id integer NOT NULL, name character varying(300) NOT NULL, CONSTRAINT tablename_pkey PRIMARY KEY (id) ) WITH ( OIDS=FALSE ); CREATE INDEX tablename_name_idx ON search.tablename USING btree (name COLLATE pg_catalog."default"); It has ~73k rows and was just vacuumed/analyzed by manual run. What I cannot understand is why this trivial query SELECT * FROM "tablename" AS "arn" WHERE arn.name LIKE 'foo%' does not use the

ImportError while running cgi-bin on localhost - undefined symbol: lo_truncate64

試著忘記壹切 提交于 2019-12-10 23:18:19
问题 I'm trying to run a cgi-bin site on localhost. And I get the following error: <type 'exceptions.ImportError'>: /usr/local/lib/python2.7/dist-packages/psycopg2/_psycopg.so: undefined symbol: lo_truncate64 My current PostgreSQL version is 9.4.5. How can I fix the issue? 回答1: The comment by Ali Nikneshan under now deleted answer saved me couple times already when I had this same problem. Not sure why it was deleted, but here I am reposting it in hopes it helps someone: pip install -U --no-cache