Articles of postgresql

带索引build议的解释

有什么(最好是开源的)软件可以分析一个PostgreSQL的EXPLAIN,并推荐必要的索引,以加快查询?

在NGINX中使用Postgres Basic Auth将查询结果添加到代理HTTP头

我们正在尝试使用ngx_postgres模块通过NGINX进行基本authentication。 我们希望从查询结果对中检索一个值并将其添加到HTTP头,然后将其代理到另一个服务器。 我们已经成功通过postgres进行身份validation,但问题是已经将结果对传递给代理。 我们目前使用的代码如下: location = /test_auth { internal; postgres_escape $user $remote_user; postgres_escape $pass $remote_passwd; postgres_pass geo_database; postgres_query "select user_name,contract_id,access_token from schema_name.table_name where user_name=$user and password=md5($pass);"; postgres_rewrite no_rows 401; more_set_headers -s 401 'WWW-Authenticate: Basic realm="Restricted"'; postgres_output none; postgres_set $query_val 0 0 required; } location /test/ { auth_request /test_auth; proxy_pass http://back_end_server/public-dev/; proxy_set_header test $query_val; proxy_redirect http://back_end_server/public-dev/ […]

可以postgres内部的日志循环机制删除一定时间以前的日志文件吗?

我正在使用posgtres的内部日志旋转机制。 我想要将超过30天的日志文件删除。 我如何获得postgres来做到这一点? 如果postgres不支持它,我可以设置logrotate只是删除超过30天的日志? 我目前的configuration是: log_destination = 'stderr' logging_collector = on log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' #log_truncate_on_rotation = off log_rotation_age = 1440 log_rotation_size = 0

我如何查询postgresql集群的编码?

当你创build一个新的postgresql集群时,你可以为集群指定一个编码,但是我不知道如何在集群创build完成后检索它。 我已经看到,用\encoding你可以看到一个编码,但我不知道这是集群的编码或客户端的编码。 我也看到,我可以看到每个数据库使用的编码。 而SHOW server_encoding显示另一种编码。 什么是正确的方式来查询初始化过程中使用的值?

用pgAdmin III进行身份validation

有没有办法让pgadmin为本地用户执行ident auth? 如果不需要在开发机器上为我的本地用户设置密码,并且只需要使用psql和pgadmin3而不需要密码就可以了。

在Ubuntu上启动postgresql服务器时出错

我最近停止了postgresql数据库(这是完美的工作),几天后,当我尝试启动它,我得到的错误: 2011-01-03 23:56:27 CLST LOG: could not translate host name "localhost", service "5432" to address: Name or service not known 2011-01-03 23:56:27 CLST WARNING: could not create listen socket for "localhost" 2011-01-03 23:56:27 CLST FATAL: could not create any TCP/IP sockets 我正在运行Ubuntu 9.1,我正在使用通常的 /etc/init.d/postgresql-8.4 start and stop 任何提示?

在同一台Ubuntu服务器上运行PostgreSQL的多个版本

我在同一台服务器上运行PostgreSQL 8.4和9.0(Ubuntu Lucid)。 我通过apt-get(8.4使用默认的软件包源,而从https://launchpad.net/~pitti/+archive/postgresql添加了ppa)来安装它们。 当我从命令行运行一个类似“createdb”的命令或启动“psql”shell时,我的系统默认使用PostgreSQL 8.4。 那么,如何强制这些命令使用PostgreSQL 9.0而不是8.4呢?

PostgreSQL服务initdb不起作用

我在我的Fedora 16上安装了PostgreSQL 9.1.2,使用类似于这里提到的方法,并对其进行了testing,这意味着我的安装工作正常。 但是当我这样做: service postgresql initdb甚至service postgresql-9.0 initdb我得到的错误: Redirecting to /bin/systemctl initdb postgresql.service Unknown operation initdb 正因为如此,我也无法启动pgAdmin3。 我错过了什么?

PostgreSQL如何处理大量的数据库?

我们有一个Web应用程序,其架构要求任何注册用户(一个公司,实际上)都应该与另一个隔离开来,也就是说,我将使用相同的数据模型运行相同的Web应用程序,但是为每个客户提供不同的数据集。 所以,我们确实考虑在每个客户的Postgres中创build一个不同的数据库。 这个解决scheme可以扩展到10-20K数据库吗? 多好? 有没有人有更好的解决scheme呢? 提前致谢。

Postgres远程访问

我试图远程连接到postgres。我已经按照本教程http://www.cyberciti.biz/faq/howto-fedora-linux-install-postgresql-server/执行以下命令来查看远程访问是可能的。 [root@printmyworld ~]# egrep -i "(listen_addresses|port|tcpip_socket).*=.+" /var /lib/pgsql/data/postgresql.conf #listen_addresses = '*' # what IP address(es) to listen on; #port = 5432 [root@printmyworld ~]# lsof +c0 -anPiTCP -upostgres COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME postmaster 9323 postgres 3u IPv4 2875987353 TCP 127.0.0.1:5432 (LISTEN ) postmaster 9323 postgres 4u IPv6 2875987354 TCP [::1]:5432 (LISTEN) […]