I am using postgresql db,
When I execute this following Query in postgresql it is running very Slow.
select * from <table_name>;
Previously it takes 5ms but now it takes around 15 mins still it is running.
Can anyone suggest what are the possible reason?
Related
I'm doing a huge upgrade on a Database. I have quite a complex query that needs a few hours to run - I tested it on some sample data and the query is fine.
After analyzing my queries, I saw that my query changed from state 'ACTIVE' to 'IDLE' after running for 3:30h.
What does that exactly mean? The PostgreSQL manual indicates that this means the transaction is open (inside BEGIN) and idle. I
Will my query end? Should I kill it and find a smarter way to upgrade?
To test my application I need a query to run for a long time (at least a couple of minutes). Any ideas on how to create this quickly?
The application needs to query the catalog to see a list of running queries.
My application uses postgresql. I am fine with creating additional dummy tables if required.
this will run for 5 minutes:
select pg_sleep(5 * 60);
the parameter for pg_sleep() is the duration in seconds.
You can also sleep until a specific timestamp using pg_sleep_until()
More details in the manual:
http://www.postgresql.org/docs/9.5/static/functions-datetime.html#FUNCTIONS-DATETIME-DELAY
I have executed a plv8 function on pgadmin 4, that uses nested for loops and some array functions.
This query was stopped using pgadmin cancel query (stop) button in GUI.
24 hours later, This query still shows up as active and running.
I have Tried, pg_cancel_backend and pg_terminate_backend, but seems to have no impact.
Tried pg_ctl kill (TERM/ABRT/INT)command, but pid is not found.
However, AWS performance insights dashboard shows up, the query using 25-30% of CPU.
If you guys could suggest alternate ways, to terminate this query, That'd be really helpful.
Thanks.
PostgreSQL 9.5.
A very small update SQL uses very high CPU for a long time like a hang.
My Windows console application uses a simple UPDATE statement to update the latest time as follows.
UPDATE META_TABLE SET latest_time = current_timestamp WHERE host = 'MY_HOST'
There are just 2 console applications which issue above SQL.
No index on META_TABLE.
Only 1 row.
When it is hanging, no lock information.
UNLOGGED Table.
IDLE status in pg_stat_activity
Commit after UPDATE.
During that the hang time, I can INSERT or DELETE data with the table above.
After starting the application, about in 20 minutes, this issue happens.
I think it is not a SQL statement or table structure issue, probably something wrong in a database side.
Can you guess anything to resolve this issue?
Update
There are 2 db connections in the console application. 1 for Select & 1 for DML.
I tried to close DML DB connection every 2 minutes. Then, I haven't seen the issue!! However, the hang issue happened on SELECT statement (also very simple SELECT).
It seems that there is a some limit per the session.
Now, I am also closing the Select db connection as well per 3 minutes and monitoring.
I have pgpool installed on my server but I am facing issue while optimising it. I have 2 different queries running on the same table-
1st is update query which runs every 1 min and query exec time is around 30 secs. So technically it is running every 30 secs.
2nd is select query.
The issue I am facing here is that update query is running and i try to run select query , my pg-pool process only update query and until unless update query is not finished it wont process my select query.
As of now, I am following the pg-pool default settings.
Any kind of feedback will be helpful: