postgresql-9.1

How to list all prepared statements for all active sessions?

跟風遠走 提交于 2019-12-01 17:04:03
I know that there is a way to list all prepared statements for the current session by selecting all rows from the pg_prepared_statements table, but is there a way to see all prepared statements for all active sessions ? I think I'm looking for something like an administrator function, but I can't find anything like it in the docs. Nope. AFAIK prepared statements are local to a backend; other backends just don't know they exist. You'd need to modify the server to add additional inter-process communication to allow one backend to ask the others about prepared statements. The backends initally

Join a count query on a generate_series in postgres and also retrieve Null-values as “0”

蹲街弑〆低调 提交于 2019-12-01 15:55:07
What I want to get is a statistic with each month from a generate_series and the sum of the counted id's in every month. This SQL works in PostgreSQL 9.1: SELECT (to_char(serie,'yyyy-mm')) AS year, sum(amount)::int AS eintraege FROM ( SELECT COUNT(mytable.id) as amount, generate_series::date as serie FROM mytable RIGHT JOIN generate_series( (SELECT min(date_from) FROM mytable)::date, (SELECT max(date_from) FROM mytable)::date, interval '1 day') ON generate_series = date(date_from) WHERE version = 1 GROUP BY generate_series ) AS foo GROUP BY Year ORDER BY Year ASC; And this is my output "2006

How to list all prepared statements for all active sessions?

隐身守侯 提交于 2019-12-01 15:45:51
问题 I know that there is a way to list all prepared statements for the current session by selecting all rows from the pg_prepared_statements table, but is there a way to see all prepared statements for all active sessions ? I think I'm looking for something like an administrator function, but I can't find anything like it in the docs. 回答1: Nope. AFAIK prepared statements are local to a backend; other backends just don't know they exist. You'd need to modify the server to add additional inter

Getting name of the current function inside of the function with plpgsql

Deadly 提交于 2019-12-01 15:34:20
Is there anyway from within a plpgsql function that you can get the name of the function? Or even the OID of the function? I know there are some "special" variables (such as FOUND) within plpgsql, but there doesn't seem to be any way of getting this. (Although, I've read where it seems to be possible if your function is written in C). It's not critical, but it would make something I'm doing a little nicer/less fragile. I'm using PostgreSQL v. 9.1.5 For triggers use TG_NAME to get the name of the trigger (not the trigger function) fired. You also have current_query() to get the top level query

Efficient way to import a lot of csv files into PostgreSQL db

折月煮酒 提交于 2019-12-01 15:09:41
问题 I see plenty of examples of importing a CSV into a PostgreSQL db, but what I need is an efficient way to import 500,000 CSV's into a single PostgreSQL db. Each CSV is a bit over 500KB (so grand total of approx 272GB of data). The CSV's are identically formatted and there are no duplicate records (the data was generated programatically from a raw data source). I have been searching and will continue to search online for options, but I would appreciate any direction on getting this done in the

Join a count query on a generate_series in postgres and also retrieve Null-values as “0”

左心房为你撑大大i 提交于 2019-12-01 14:59:16
问题 What I want to get is a statistic with each month from a generate_series and the sum of the counted id's in every month. This SQL works in PostgreSQL 9.1: SELECT (to_char(serie,'yyyy-mm')) AS year, sum(amount)::int AS eintraege FROM ( SELECT COUNT(mytable.id) as amount, generate_series::date as serie FROM mytable RIGHT JOIN generate_series( (SELECT min(date_from) FROM mytable)::date, (SELECT max(date_from) FROM mytable)::date, interval '1 day') ON generate_series = date(date_from) WHERE

Trouble connecting to Postgresql database in Vagrant guest box with Induction from host machine?

為{幸葍}努か 提交于 2019-12-01 13:53:46
I'm trying to connect to my PostgreSQL database which is inside of a guest machine (using Vagrant and VirtualBox). I'm trying to connect to it with Induction , but I am getting an error saying: Connection Error Could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.1234" I have Vagrant doing a port forward to port 1234 on my host machine. My settings for the Induction connection are: Adapter: postgres Host Name: 127.0.0.1 Username: vagrant Password: [i don't have a password for the vagrant user

Trouble connecting to Postgresql database in Vagrant guest box with Induction from host machine?

末鹿安然 提交于 2019-12-01 13:12:08
问题 I'm trying to connect to my PostgreSQL database which is inside of a guest machine (using Vagrant and VirtualBox). I'm trying to connect to it with Induction, but I am getting an error saying: Connection Error Could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.1234" I have Vagrant doing a port forward to port 1234 on my host machine. My settings for the Induction connection are: Adapter:

Postgres find configuration files in linux

荒凉一梦 提交于 2019-12-01 09:37:35
I've spent lots of time to find Postgres configuration files like pg_hba.conf or postgresql.conf in different distributions of linux and also postgres versions itself! and I was very confused... Finally I found the global solution for it. First you should follow these steps: su - postgres psql For postgres configuration file : SHOW config_file; the output should be like this: postgres=# SHOW config_file; config_file ------------------------------------------ /etc/postgresql/9.6/main/postgresql.conf (1 row) and for hba_file use: SHOW hba_file; If you instance is not started and you can't select

Postgres find configuration files in linux

我怕爱的太早我们不能终老 提交于 2019-12-01 08:22:53
问题 I've spent lots of time to find Postgres configuration files like pg_hba.conf or postgresql.conf in different distributions of linux and also postgres versions itself! and I was very confused... 回答1: Finally I found the global solution for it. First you should follow these steps: su - postgres psql For postgres configuration file : SHOW config_file; the output should be like this: postgres=# SHOW config_file; config_file ------------------------------------------ /etc/postgresql/9.6/main