Can we pass a varchar/text datatype in to a variable in pgbench?
–pgbench sql script [pg93@db1 load_test]$ cat get_email.sql setrandom cnt 1 100000 set v_username 'user_' || :cnt begin; select get_user_email(:v_username); end; get_user_email() is a function which...
View ArticleST_GeomFromGeoJSON() Causes postgres to crash
I’m running into a strange problem which I can’t solve. The server crashes when executing some postgis related queries. After some debugging, using the examples provided by postgis, it appears the...
View ArticleDo Postgres GIN indexes need to be rebuilt periodically?
Do they get bloated like btree indexes? If so how can the bloat be measured e.g. by an automated reindexing script. I am interested in improving query performance and saving space.
View ArticleSQL Statements truncated in log files
Does PostgreSQL cut statements if there is a subselect in it? We use log_min_duration_statement = 20ms to find statements which need a long time. But unfortunately the statements are truncated:...
View ArticlePartial db dump/restore
A part of my database (PostgreSQL 9.3) relies on extra tables (ex. County, City, Town, … ). I don’t manage these tables, they are updated regularly by a third party. Each time I get a new full dump,...
View ArticleInsert of select id on multiple tables
When importing some data (10000) rows each time, I need to perform an INSERT or SELECT (insert if doesn’t exist or select if exist and return table_id) 7 times for each row. At the moment I use the...
View ArticleWhere to download (Dutch) Postgresql Fulltext Search dictionaries
PostgreSQL enables me to configure what dictionaries I would like to use when preforming a fulltext search. The following types of dictionaries can be set: stop ispell simple snowball synonym thesaurus...
View ArticlePostgres: modify existing search_path (preserve current values)
Sometimes I would like to extend the existing search path, rather than replace it, say: To start with say it is already set like so: SET search_path TO schema_b, schema_c, public; I want to add my...
View ArticleHow to keep the sync active with Bucardo
I have a master-master sync setup between 3 nodes or 3 different host machines using bucardo. All works good. However when one of the database or a host is not reachable or goes down for some reason,...
View ArticlePostgresql and UTF8 to Latin1 conversion?
We have a Postgresql database where the data is in Latin1. Apparently someone loaded some UTF8 encoded data into it since when I select data from some of the columns, I get stuff like: SELECT symptoms...
View ArticleUsing Configuration Management for DBA tasks?
We have a couple of Postgres 9.3 database servers in our system, all of them with their respective config files, databases, roles, role groups, permissions on schema/tables, extensions etc. We use...
View ArticleIs product purchaser in distribution area?
I am going to be using PostGIS 2 to create a lookup service. Given a point (lat/lon), I need to either find if a product can be distributed there, or b) a list of products or distributors. I am...
View ArticleSort by number of related rows in referencing table
Let there be two tables: Users id [pk] | name --------+--------- 1 | Alice 2 | Bob 3 | Charlie 4 | Dan Emails id | user_id | email ----+---------+------- 1 | 1 | a.1 2 | 1 | a.2 3 | 2 | a.3 4 | 2 | b.1...
View Articlehow are passwords encoded in pg_shadow
How are passwords encoded in column passwd of pg_shadow? Doing a: select passwd from pg_shadow; I see values like the following: md52c92c858aa1fa12144f1dcbd4ca9c3a0 … which, doesn’t seem to be what I...
View ArticlePrevent Primary Key increment when an INSERT statement fail in PostgreSQL
I have a simple table in my PostgreSQL database like this: CREATE TABLE person_type ( id serial NOT NULL, name character(55) NOT NULL, CONSTRAINT person_type_pkey PRIMARY KEY (id), CONSTRAINT...
View ArticlePerformance of single vs multiple column unique constraint
I’m using PostgreSQL 9.3. I want to understand if I have an option to make a constraint unique across the entire table vs. unique across a subset of the table (i.e. by using 2 columns in the unique...
View ArticleArray column vs another table when the relationship is quite small
The Data I am creating a table of cities and their zip codes for the United States. Some zip codes have a list of acceptable cities, as designated by the USPS. For example, the zip code 36613 is...
View ArticleGet seconds of day in Postgres
In Java we use Joda-Time to get the seconds of a day as an int value (despite the date): date: 10-10-2014 00:00:30 -> second 30 of day date: 11-10-2014 00:01:30 -> second 90 of day date:...
View ArticleMigrate SQL Server binary datadump to postgresql
I just got a very big dataset (+/-55GB) in a binary SQL Server format. Is there an easy way to import this file into a Postgresql Server? I found some converter-programs, but they ‘only’ convert from...
View ArticleHow to connect to an Amazon PostgreSQL database using SSL
I’m trying to log into an Amazon PostgreSQL DBS using SSL. I have all credentials but my psql version doesn’t seem to support SSL. I’ve tried searching Postgres docs but all I see is how it has native...
View Article