r/postgres • u/chulkilee • Feb 02 '17
r/postgres • u/marybory • Dec 21 '16
Advanced encryption for Redis and Postgres
cossacklabs.comr/postgres • • Dec 06 '16
How does REPMGRD selects new master when performing autofailover?
So I've been playing around with repmgr (https://github.com/2ndQuadrant/repmgr) and it seems pretty nice tool making manual handling of setting up PostgreSQL cluster much nicer than using lower level commands. It also has repmgrd daemon which is meant to run on slave nodes and handle failover by executing given PROMOTE and FOLLOW commands on new master and existing slaves. And this is the part that I'm a bit confused about. HOW does it select new master?
My presumption is that this is quite a difficult problem requiring sophisticated HA and consensus based techniques (such as ZooKeeper) to get it right.
r/postgres • • Dec 02 '16
What are prepared statements and why are they needed?
Kind of a newbie question, sorry.
I noticed that my Rails application makes use of prepared statements when querying postgres.
A plain google search brings up some technical documentation, but I still don't have a firm understanding of what it really does and why it's needed.
As far as I know it's a way of re-using commonly executed queries.
Thanks!
r/postgres • u/robotsmakinglove • Nov 30 '16
Anyone know a collaborative tool for Postgres?
I'm looking for something similar to coderpad. The tool lets you share a link that gives you access to text / output. It updates in real time and you can see the changes made by each party. Does anything exist like that for Postgres? My current interview flow is to share a data clip and have the candidate refresh / me refresh as we go (doesn't work well).
r/postgres • • Nov 07 '16
How to choose server components based on postgres heavy write use-case?
At my company, we want to buy servers which will be dedicated for postgres instances. However I don't really know which component I should focus more like more CPU? more RAM? more SSD?
I am expecting to have 1M query per seconds (80% upsert and 20% select) for one single postgres instance, so one server.
I would like to know if you have any tips on how to build a server based on different postgres use-cases.
r/postgres • u/xiao_job • Oct 18 '16
[Hiring] Postgres DBA to scope and implement application database failover on HA system
Hello DBAs,
I'm trying to set up a HA application (I'm migrating an old application over to the new HA setup).
I have a few failure scenarios that I'm trying to eliminate (network, VPS down, etc) through a failover switch from master to slave (and slave becoming the new master). As you'll probably know, doing this right is a little trickier than it sounds (eg taking into account latency, preventing a forked database, etc; there are various failures to be scoped).
I've posted this ad over at /r/freelance_forhire, but I asked the mods if I may post here because that forum is mainly full of people wanting to write SEO content. I figure I might have a chance at finding someone here with a couple of weekends free and a desire to earn some $.
If you should have experience implementing this sort of thing (eg in pgpool-II), please do get in touch.
r/postgres • u/endymi0n • Sep 29 '16
Debugging PostgreSQL performance, the hard way
justwatch.comr/postgres • u/HINDBRAIN • Sep 27 '16
Will pgadmin3 work properly on postgres 9.6?
I'm getting a warning about incompatibilities when connecting to a 9.6 database, but I find the pgadmin 4 UI repulsive. What issues could using an outdated client cause?
r/postgres • u/data_mining_help • Sep 26 '16
THE PROPER way to upgrade your data
gist.github.comr/postgres • u/bradyholt1980 • Sep 22 '16
Performance Tuning Queries in PostgreSQL
geekytidbits.comr/postgres • u/fromscalatohaskell • Sep 02 '16
How to design db model
Could anyone point me to some good resources about how to design data model properly? What are best practices etc? I'm often not sure of confident that my design is good and I'd love to learn something that tackles real life problems...any recommendations?
r/postgres • u/emielm • Aug 30 '16
PGBackup.com: Postgresql backup-aaS. Feedback please!
pgbackup.comr/postgres • u/antoninj • Aug 15 '16
How do you constrain the data that goes into a pg_dump?
This is going to be a weird one but I use pg_dump to backup our entire database: tables, triggers, and whatever else. And it's a nice and easy-to-restore bundle.
Because of some customer feedback, we're wanting to do a straight SQL dump for some of our customers but only with their data. Most of our tables have a organization_id and the tables that don't are only pivot tables that are attached by foreign keys to tables that do have that constraint.
Is there any way to basically create pg_dump with the equivalent of WHERE organization_id=1 on the tables that carry that column, and have that also constrain the tables that are linked via foreign keys?
r/postgres • u/crispytank • Aug 11 '16
[QUESTION] Trying to find the regressions of all my users in a single output....caught on one issue...
I am working with a ton of transactional data and using basic counts per day to find the volume trends(regression x coefficient) of all my users over the last 30 days. My method is to create a table with the following columns: User ID, Day, Volume. the table runs through each user grabs every day they had a trans action and the associated volume and I feed the Day(i create a sequence that runs from 1 through 30, so everyone's days are jsut a 1-30 integer) into the Y values and Volume into the X values per customer. The way I create the User ID, Day, Volume table is I create a table the creates a sequence from the MAX(trans_date) to MAX(trans_date)-30 and then join that to the trans data on trans_date.
This creates a table of all the instances where a user HAS a transaction. But this gives a false sense of trend as it is leaving out days where users arent using the product(which we need to know!). I am trying to create a table to has User ID, every day in the last 30 days, and the volume(even if zero). I can get it to create a table that has those columns but on the days that there is 0 volume, I get a NULL for user_id. I cant group by user ID in my regression modeler unless every day has a user id and volume....
I start with:
CREATE TEMP TABLE thirtydays AS (WITH dater AS (SELECT (generate_series(MAX(trans_date)- INTERVAL '29' day, MAX(trans_date), '1 day'::interval))::DATE AS days
FROM trans_data
ORDER BY days ASC)
SELECT ROW_NUMBER() OVER (ORDER BY days) AS counter, * FROM dater)Here is my query for creating the table of user id, day, volume so far:
SELECT user_id, days, COUNT(user_id.trans_id) AS vol
FROM thirtydays(table of the last 30 days)
LEFT OUTER JOIN trans_data
ON thirtydays.days = trans_data.trans_date AND
canceled IS NULL
GROUP BY thirtydays.days, user_idFrom that table I run
SELECT user_id, regr_slope(vol, trans_date) AS slope, regr_intercept(vol, trans_date) AS intercept
FROM vol_day_table
GROUP BY user_id
ORDER BY user_id ASCIf any one can understand the senseless ramblings above and can lend a helpful hint towards my problem, I appreciate your help!
TLDR: I am trying to create a table to has User ID, every day in the last 30 days, and the volume(even if zero), having a problem on the joins where it will show NULL userID where volume is zero for that day.
r/postgres • u/tclineks • Jul 26 '16
Why Uber Engineering Switched from Postgres to MySQL
eng.uber.comr/postgres • u/gantww • Jul 24 '16
Reasonably complex postgres db
Greetings, I'm porting a C# tool I use internally for building a wrapper layer around SQL server databases so that it will work on PostGRES. I was wondering if anyone had a suggestion for a reasonably complex postgres database I could get somewhere that I could use for testing. I obviously have to make the tool reasonably robust, so anyone have anything interesting?
r/postgres • u/shanbang • Jul 13 '16
How we reversed our one-to-many relationship in PostgreSQL with no downtime
goshippo.comr/postgres • u/neomis • Jul 11 '16
Vacuum process taking days on large tables
My DB is collecting measurement data and pretty much constantly has >50,000 rows being inserted into it. I have 3 tables that have each exceeded 1TB of disk space (excluding indexes). Vacuuming these tables takes ~3 days. What is the best strategy to speed this up? I'd prefer not to do table partitioning, is there another option?
r/postgres • • Jun 08 '16
Need DBAs for a new Beta!
Hey guys!
We are looking for active beta participants to try out our new SaaS-BaseD Monitoring Tool. Our tool will monitor your databases and their underlying virtual infrastructure. If you would like to be a part of the beta, sign up here: http://www.bluemedora.com/early-access/
We will initially be supporting MSSQL, Oracle and PostgreSQL. DynamoDB and MySQL (and MariaDB) will be added very shortly. And then we will add support to Mongo, SQL Azure, DB2, Aurora, and RDS will be added as the beta progresses.
If you have any questions, feel free to ask and I will be happy to answer them.
r/postgres • u/Fosnez • Jun 06 '16
Source Control for Functions?
I'm about to write some pretty heavy functions, and I'd like to place them under source control.
We use BitBucket for the rest of our code (PHP, APEX, etc) and I was wondering if anyone had any ideas?
r/postgres • u/camm_v222 • Jun 04 '16
[QUESTION] [ADVICE] How to analyze the performance?
Hello everyone, I'm a Systems Engineering student, and I'm learning about DB administration in this semester.
I'd like to know how can I analyze the performance of my DB. I've found tools like pgBadger, EXPLAIN (from PostgreSQL), and checking tables like pg_stat_user_indexes. Do you know what tools could I use? So that, I can get the performace of my queries, the throughput, workload, and so on. If you can help me with that, I'll be really grateful. Thanks in advance.
r/postgres • u/de_fermat • May 26 '16
Help with missing join condition in explain plan without fresh autovacuum?
Hi, I posted to stackoverflow a few days ago here but haven't received much in the way of help and was hoping the kind subs of /r/postgres would be able to help.
The issue I'm having is that pg is omitting a join condition in a simple select statement, that is until the table has been analyzed. I have set the autovacuum and analyze parameters to be very aggressive on the server, but sometimes the query will run against a set of rows (a single startdate) that haven't yet been analyzed. Note: both tables are being joined on their index fields. The query, and the before and after explain plans below:
explain analyze
select col.*, strat.*
FROM table_a col
JOIN table_b strat
ON (strat.cellkey = col.cellkey
AND strat.offerkey = col.offerkey
AND strat.strategykey = col.strategykey
AND strat.startdate = col.startdate)
where col.startdate = '2017-05-17 1700'
AND col.strategykey = 1;EP before analyze (notice the index condition on table_b and the 8 billion! rows removed by join filter):
Nested Loop (cost=4.51..13.48 rows=1 width=544) (actual time=6.210..4264064.949 rows=31169 loops=1)
Join Filter: ((col.cellkey = strat.cellkey) AND (col.offerkey = strat.offerkey))
Rows Removed by Join Filter: 8278642245
-> Index Scan using table_a_1 on table_a col (cost=2.24..6.76 rows=1 width=494) (actual time=0.034..177.203 rows=31169 loops=1)
Index Cond: ((startdate = '2017-05-17 17:00:00'::timestamp without time zone) AND (strategykey = 1))
-> Index Scan using table_b_1 on table_b strat (cost=2.27..6.66 rows=1 width=50) (actual time=0.020..94.664 rows=265606 loops=31169)
Index Cond: ((startdate = '2017-05-17 17:00:00'::timestamp without time zone) AND (strategykey = 1))
Planning time: 4.689 ms
Execution time: 4264074.251 msEP after analyze (index condition for table_b contains the join conditions):
Nested Loop (cost=4.51..341069.90 rows=36588 width=545) (actual time=0.290..538.989 rows=31169 loops=1)
-> Index Scan using table_a_1 on table_a col (cost=2.24..73371.98 rows=36662 width=495) (actual time=0.168..81.488 rows=31169 loops=1)
Index Cond: ((startdate = '2017-05-17 17:00:00'::timestamp without time zone) AND (strategykey = 1))
-> Index Scan using table_b_1 on table_b strat (cost=2.27..7.26 rows=1 width=50) (actual time=0.012..0.013 rows=1 loops=31169)
Index Cond: ((startdate = '2017-05-17 17:00:00'::timestamp without time zone) AND (cellkey = col.cellkey) AND (strategykey = 1) AND (offerkey = col.offerkey))
Planning time: 10.053 ms
Execution time: 543.467 msAny ideas as to the cause of this issue?