pgtune | Pgtune - tuning PostgreSQL config by your hardware | Database library
kandi X-RAY | pgtune Summary
kandi X-RAY | pgtune Summary
Tuning PostgreSQL config by your hardware. Based on original pgtune. Illustration by Kate.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pgtune
pgtune Key Features
pgtune Examples and Code Snippets
Community Discussions
Trending Discussions on pgtune
QUESTION
I'm a Postgresql newbie, so still struggling a little bit here. Please be gentle.
I'm left joining three tables, and would like to be able to use a case statement to introduce another column that brings across a desired value from one column based on another. I'm going to guess that my INNER JOIN and CASE statements are back to front, but I'm not sure how to rearrange them without breaking the intent.
Basically: Where model_best_fit == SUNNY, then I'd like a new column with name applied_f_model_hours_above4k to have the value from the column hoursabove4k_sunny
Code sample:
...ANSWER
Answered 2021-Apr-15 at 06:00In a table, all rows have the same columns. You cannot have a column that exists only for some rows. Since a query result is essentially a table, that applies there as well.
So having NULL or 0 as a result for the rows where the information does not apply is your only choice.
The reason why the CASE
expression is returning NULL is that you have no ELSE
branch. If none of the WHEN
conditions applies, the result is NULL.
The performance of the query is a different thing. You'd need to supply EXPLAIN (ANALYZE, BUFFERS)
output to analyze that. But when joining big tables, it is often beneficial to set work_mem
high enough.
QUESTION
I usually use http://pgtune.leopard.in.ua/ for tuning postgresql parameters depending on hardware resources.
But now I want to tune two clusters on same server.
How should I tune PostgreSQL configuration in this case?
For the sake of simplicity let say both clusters would be under similar load.
Now with this setup:
...ANSWER
Answered 2019-Sep-06 at 12:05There is not much you can configure here. The exceptions are:
shared_buffers
,work_mem
andmax_connections
: these three determine your memory usage. You need to divideshared_buffers
andmax_connections
orwork_mem
between the clusters.effective_cache_size
: split that as well.effective_io_concurrency
should be split as well.
Most resources cannot be controlled effectively from the configuration. You may want to give pg_cgroups
a try (disclaimer: I am the author).
QUESTION
I added a new extension (timescaledb) like this:
...ANSWER
Answered 2019-Feb-18 at 19:48Timescale person here. Will need to understand more about your setup (which version of Timescale, which platform, which OS, etc.) to be able to help.
Please see the info we ask on our github: https://github.com/timescale/timescaledb/issues/new/choose
But in general, the proper way in PG to remove an extension in DROP EXTENSION
, not mucking with things internally in the pg_extension
table (presumably with super-user permissions)? I'm not sure what state you've left the database.
QUESTION
I have simple query that must get 1 record from table with about 14m records:
...ANSWER
Answered 2018-Sep-25 at 18:56You are filtering your data on status
and tool_id
, and sorting on updated_at
but you have no single index for all three of those columns.
Add an index, like so:
CREATE INDEX ON projects_toolresult (status, tool_id, updated_at);
QUESTION
I'm trying to optimise a query, as the query generated by my ORM (Django) is causing timeouts. I've done everything possible within the ORM to run it as one query, so now I wanted to know if there are any Postgres tricks that can speed things up.
The database contains 1m+ and growing relationships (id, source and target) which I need to filter to exclude connections where the source doesn't appear at least 2 times.
This is the current query - and the list of "target" ids can grow which leads to exponential slowdowns.
...ANSWER
Answered 2017-May-13 at 08:17Your query is already optimal. There is no way to avoid scanning the whole table to get the information you need, and a sequential scan is the best way to do that.
Make sure that work_mem
is big enough that the aggregationcan be done in memory – you can set log_temp_files
to monitor if temporary files are used (which makes things much slower).
QUESTION
For the past few weeks I've been tuning and messing with PostgreSQL which I'm going to use with my next project.
My Specs are:
- DigitalOcean 8 Cores 16GB SSD x2 (One for DB, another for Web)
- Centos 7
- PHP5 , Nginx
The things that I've tried:
Pgtune
PgBouncer & Pgpool (connection pooling & load balancing)
Tuning php-fpm & nginx (worker_processes, worker_connections, pm.max_children etc)
Linux file handle limits and socket tweaking.
I'm testing it by calling the webpage with ApacheBench to insert. Is it practical?
...ANSWER
Answered 2017-Mar-27 at 06:53The best load test is with a real-world load; the closer to that your load test is, the better.
If you have many concurrent requests, connection pooling is a must and pgBouncer is the standard answer.
It is impossible to do performance tuning in the scope of an answer, and indeed this question will probably be closed for being too broad, but I'll give you some general leads:
The goal is to find the bottlenecks, that is resources where your system is at the limit. Narrow it down: is it the application, the web server, or the database? Once you know which component limits you, find the individual limiting resource. Is it I/O? CPU time? Memory? The time it takes to establish a database connection? Locks?
One important rule is not to start twiddling knobs at random before you know where the problem is. That is likely to give you a misconfigured system. Find a theory, try a solution, and if it does not have the desired effect, reset the setting to the value it had before.
I don't understand your setup: First you say that you have a machine for the database and one for the application, then you say that you tried local socket connections.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pgtune
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page