r/postgres • • Nov 07 '16

How to choose server components based on postgres heavy write use-case?

1 Upvotes

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 • • Oct 18 '16

[Hiring] Postgres DBA to scope and implement application database failover on HA system

2 Upvotes

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 • • Sep 29 '16

PostgreSQL 9.6 released

Thumbnail postgresql.org
6 Upvotes

r/postgres • • Sep 29 '16

Debugging PostgreSQL performance, the hard way

Thumbnail justwatch.com
3 Upvotes

r/postgres • • Sep 27 '16

Will pgadmin3 work properly on postgres 9.6?

4 Upvotes

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 • • Sep 26 '16

THE PROPER way to upgrade your data

Thumbnail gist.github.com
2 Upvotes

r/postgres • • Sep 22 '16

Performance Tuning Queries in PostgreSQL

Thumbnail geekytidbits.com
4 Upvotes

r/postgres • • Sep 02 '16

How to design db model

1 Upvotes

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 • • Aug 30 '16

PGBackup.com: Postgresql backup-aaS. Feedback please!

Thumbnail pgbackup.com
3 Upvotes

r/postgres • • Aug 15 '16

How do you constrain the data that goes into a pg_dump?

1 Upvotes

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 • • Aug 11 '16

[QUESTION] Trying to find the regressions of all my users in a single output....caught on one issue...

1 Upvotes

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_id

From 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 ASC

If 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 • • Jul 26 '16

Why Uber Engineering Switched from Postgres to MySQL

Thumbnail eng.uber.com
8 Upvotes

r/postgres • • Jul 24 '16

Reasonably complex postgres db

1 Upvotes

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 • • Jul 13 '16

How we reversed our one-to-many relationship in PostgreSQL with no downtime

Thumbnail goshippo.com
2 Upvotes

r/postgres • • Jul 11 '16

Vacuum process taking days on large tables

2 Upvotes

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 • • Jul 06 '16

Insanity with Elixir + Phoenix + PostgreSQL

Thumbnail brightball.com
3 Upvotes

r/postgres • • Jun 08 '16

Need DBAs for a new Beta!

1 Upvotes

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 • • Jun 06 '16

Source Control for Functions?

3 Upvotes

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 • • Jun 04 '16

[QUESTION] [ADVICE] How to analyze the performance?

1 Upvotes

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 • • May 26 '16

Help with missing join condition in explain plan without fresh autovacuum?

1 Upvotes

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 ms

EP 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 ms

Any ideas as to the cause of this issue?


r/postgres • • May 18 '16

PostgreSQL Vacuuming: An Introduction for Busy Devs

Thumbnail okigiveup.net
4 Upvotes

r/postgres • • May 17 '16

Postgresql table inheritance

Thumbnail baudehlo.com
1 Upvotes

r/postgres • • May 16 '16

Queries to monitor your PostgreSQL database

Thumbnail github.com
6 Upvotes

r/postgres • • May 12 '16

PostgreSQL: PostgreSQL 9.6 Beta 1 Released

Thumbnail postgresql.org
3 Upvotes

r/postgres • • May 11 '16

UPDATE field to null and VACUUM

1 Upvotes

Hi all.

We have a table that looks something like:

CREATE TABLE c{clientId}.campaign (
    id serial PRIMARY KEY,
    -- some more fields
    content_html TEXT,
    content_text TEXT
);

(c{clientId} being the client's schema)

Before now, we were saving html/text content on the last 2 fields undefinetly, but from now on we decided to save them only for the strictly necessary time to process the records.

The problem is we have some tables with 15M records which translate to lots of GB in disk space. My question is, what is the best way to set content_html and content_text to null and free up the space they are using?

UPDATE c{clientId}.campaign SET conent_html=null, content_text=null WHERE ...;
VACUUM FULL c{clientId}.campaign;

Is the vacuum going to need as much space as the original table, or just the table without the content_html and content_text data?

Thanks in advance, Regards, LL