postgresql-10

postgresql streaming replication slow on macOS

ⅰ亾dé卋堺 提交于 2019-12-23 01:42:34
问题 I am using PostgreSQL 10.1 on MAC on which I am trying to set up streaming replication. I configured both master and slave to be on the same machine. I find the streaming replication lag to be slower than expected on mac. The same test runs on a Linux Ubuntu 16.04 machine without much lag. I have the following insert script. for i in $(seq 1 1 1000) do bin/psql postgres -p 8999 -c "Insert into $1 select tz, $i * 127361::bigint, $i::real, random()*12696::bigint from generate_series('01-01-2018

could not load library plpython3.dll

不羁岁月 提交于 2019-12-20 01:46:51
问题 i am getting error while creating extension in Postgresql version 10 could not load library "C:/Program Files/PostgreSQL/10/lib/plpython3.dll": The specified module could not be found CREATE EXTENSION plpython3u; could not load library "C:/Program Files/PostgreSQL/10/lib/plpython3.dll": The specified module could not be found Using Postgresql 10 on Window 10 回答1: I have struggled a lot with this. For me only worked when I installed the right version of python and added paths to environment

could not load library plpython3.dll

余生长醉 提交于 2019-12-20 01:46:00
问题 i am getting error while creating extension in Postgresql version 10 could not load library "C:/Program Files/PostgreSQL/10/lib/plpython3.dll": The specified module could not be found CREATE EXTENSION plpython3u; could not load library "C:/Program Files/PostgreSQL/10/lib/plpython3.dll": The specified module could not be found Using Postgresql 10 on Window 10 回答1: I have struggled a lot with this. For me only worked when I installed the right version of python and added paths to environment

How do I improve date-based query performance on a large table?

拜拜、爱过 提交于 2019-12-19 10:08:05
问题 This is related to 2 other questions I posted (sounds like I should post this as a new question) - the feedback helped, but I think the same issue will come back the next time I need to insert data. Things were running slowly still which forced me to temporarily remove some of the older data so that only 2 months' worth remained in the table that I'm querying. Indexing strategy for different combinations of WHERE clauses incl. text patterns How to get date_part query to hit index? Giving

I want fetch data from different different table name using postgresql function

故事扮演 提交于 2019-12-18 09:53:16
问题 I have 30 state wise data tables. Table name like aa_shg_detail, ab_shg_detail, ac_shg_detail. I have also main state table in which state short names and state codes are stored. I have created 2 postgresql functions getTableName(Code text) and getDataByTable(). In the first function I pass the state code so it fetches the state short name and short name concat with _shg_detail String and prepare full table name and return it. Example: If I pass state code 2 the query fetch state short name

How to use default schema privileges on functions in Postgres in right way?

笑着哭i 提交于 2019-12-13 17:25:59
问题 I am struggling to comprehend how default schema privileges work in Postgres. To me, they are something that supposed to ease administration load by issuing permissions automatically, but I found them bit unusable. I discovered several things that are not at all obvious from documentation. I want several users to be able to create and modify objects in schema. I create a role who gonna be the owner and grant this role to multiple (in general) users: create schema my_schema; create role my

PostgreSQL 10: With this upsert function, how to update only if column value is different?

拟墨画扇 提交于 2019-12-13 04:32:58
问题 I'm looking to update apr only if it's different, right now, it looks like it updates regardless if it's different or same: INSERT INTO live_mytable (id, loan_type, apr, term, oldestyear) SELECT id, loan_type, apr, term, oldestyear FROM imp_mytable ON CONFLICT (id,loan_type,term,oldestyear) DO update set apr = excluded.apr; How can this query be changed to only update if value is different? 回答1: You can use a WHERE clause on the update: INSERT INTO live_mytable (id, loan_type, apr, term,

What is the fastest way to rebuild PostgreSQL statistics from zero/scratch with ANALYZE?

こ雲淡風輕ζ 提交于 2019-12-13 03:46:26
问题 I have a PostgreSQL v10 database with a size of about 100GB. What is the most efficient (fastest) way to rebuild statistics, for example after a major version upgrade? ANALYZE with no parameters updates statistics for then entire database by default — it's painfully slow! This seems like a single process. Is there any way to parallelize this to speed it up? 回答1: You could use vacuumdb with the same options that pg_upgrade suggests: vacuumdb --all --analyze-in-stages The documentation

Set lc_monetary for PostgreSQL

青春壹個敷衍的年華 提交于 2019-12-11 07:19:26
问题 How do I set lc_monetary to show money (docs) data type as EUR? I tried: change postgresql.conf and set lc_monetary="de_DE.UTF-8@euro . PG will not start with this change (currently set to en_US.UTF-8 ) do the same through pgAdmin and psql (using set ) and I get ERROR: invalid value for parameter "lc_monetary" My current collation is en_US.UTF-8 . 回答1: Locales depend on the operating system. Check what locales are available select * from pg_collation where collname ~ any(array['DE', 'FR', 'GR

How correctly aggregate date in PostgreSQL database?

拥有回忆 提交于 2019-12-11 04:27:55
问题 I have table in PostgreSQL database. The table below shows you the hourly speed of trains in each underground station of the cities of England: DATE_KEY | STATION | CITY | SPEED ------------------------------------------------------- 2018-10-01 00:00:00 | Arsenal | London | 1078.125 2018-10-01 01:00:00 | Arsenal | London | 877.222 2018-10-01 02:00:00 | Arsenal | London | 1127.752 2018-10-01 00:00:00 | Beckton | London | 2866.375 2018-10-01 01:00:00 | Beckton | London | 1524.375 2018-10-01 02