postgresql

Postgresql slow delete from where exists

断了今生、忘了曾经 提交于 2021-02-20 04:05:06
问题 I'm having trouble with slow delete queries. I have a schema ,say "target" containing tables that all have an equivalent table (identical columns & primary keys) in another one, say "delta". I now want to delete all rows that appear in the delta schema from the target schema. I have tried this using the DELETE FROM WHERE EXISTS approach, but that seems incredibly slow. Here's an example query: DELETE FROM "target".name2phoneme WHERE EXISTS( SELECT 1 FROM delta.name2phoneme d WHERE

SQLAlchemy, Declarative, PostgreSQL: cannot create tables

感情迁移 提交于 2021-02-20 04:04:14
问题 I created a number of classes I want to persist to the database. I would like to be able to run the app with a specific flag to take all those classes and create the corresponding tables in my db. To that end, I'm trying to import the classes and then call the Base.metadata.create_all(engine) method. However, that doesn't work. At the same time, when I call that from the file with each of those actual classes, the tables are created. How do I go about the task of creating those tables? Should

Performance is not increased even increased the work_mem size

无人久伴 提交于 2021-02-20 02:30:53
问题 I return a query which is taking Avg of 170 seconds to execute. I went through the PSQL documentation, they mentioned that if we increase work_mem the performance will increase. I increased the work_mem to 1000 MB even the performance is not improved. Note: I indexed all the field which are the part of the query. Below I am pasting the records present in the DB, query execution plan, query, result. The number of records present in the DB: event_logs=> select count(*) from events; count ------

Performance is not increased even increased the work_mem size

泄露秘密 提交于 2021-02-20 02:30:08
问题 I return a query which is taking Avg of 170 seconds to execute. I went through the PSQL documentation, they mentioned that if we increase work_mem the performance will increase. I increased the work_mem to 1000 MB even the performance is not improved. Note: I indexed all the field which are the part of the query. Below I am pasting the records present in the DB, query execution plan, query, result. The number of records present in the DB: event_logs=> select count(*) from events; count ------

Performance is not increased even increased the work_mem size

依然范特西╮ 提交于 2021-02-20 02:30:06
问题 I return a query which is taking Avg of 170 seconds to execute. I went through the PSQL documentation, they mentioned that if we increase work_mem the performance will increase. I increased the work_mem to 1000 MB even the performance is not improved. Note: I indexed all the field which are the part of the query. Below I am pasting the records present in the DB, query execution plan, query, result. The number of records present in the DB: event_logs=> select count(*) from events; count ------

Python postgreSQL sqlalchemy query a DATERANGE column

百般思念 提交于 2021-02-19 09:42:49
问题 I have a booking system and I save the booked daterange in a DATERANGE column: booked_date = Column(DATERANGE(), nullable=False) I already know that I can access the actual dates with booked_date.lower or booked_date.upper For example I do this here: for bdate in room.RoomObject_addresses_UserBooksRoom: unaviable_ranges['ranges'].append([str(bdate.booked_date.lower),\ str(bdate.booked_date.upper)]) Now I need to filter my bookings by a given daterange. For example I want to see all bookings

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

岁酱吖の 提交于 2021-02-19 09:23:38
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

﹥>﹥吖頭↗ 提交于 2021-02-19 09:20:19
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

痞子三分冷 提交于 2021-02-19 09:19:20
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

postgresql delete partition tables

巧了我就是萌 提交于 2021-02-19 08:58:10
问题 I'm new at Postgresql and do not exactly know how to manage partition tables. I have partition table based on day. Before inserting data, trigger checks date and put into corresponding child table. eg. 11.15.2014 - insert into table named 11-15-2014_log. 11.16.2014 - insert into table named 11-16-2014_log. Now I want to create function that will drop old child tables, for example, tables older than 90 days. Should I find and drop child table according its tablename (cause it consists date of