postgresql-10

How many iterations does the scram-sha-256 setting use in PostgreSQL 10?

冷暖自知 提交于 2019-12-11 03:24:43
问题 How many iterations does the scram-sha-256 setting use in PostgreSQL 10? The docs just say Setting this parameter to scram-sha-256 will encrypt the password with SCRAM-SHA-256. The build log reads. Add SCRAM-SHA-256 support for password negotiation and storage (Michael Paquier, Heikki Linnakangas) This proves better security than the existing md5 negotiation and storage method. 回答1: It's a compile-time variable in scram-common.h known as SCRAM_ITERATIONS_DEFAULT. Currently it's set to 4096.

Can I 'recompile' table returning functions after that table is ALTER-ed during database migration?

╄→гoц情女王★ 提交于 2019-12-11 00:47:08
问题 I have a stored procedure that returns a record type. If I ALTER the table this stored procedure returns (let's say I add a column), I have to either disconnect my database session or re-run the CREATE OR REPLACE . When I don't I will get the error wrong record type supplied in RETURN NEXT . Here's a script that fails when I run it in a single psql session: CREATE TABLE p1(a INT, b TEXT); CREATE OR REPLACE FUNCTION authenticate() RETURNS SETOF p1 as ' DECLARE player_row p1; BEGIN -- query is

Why is the query planner unable to transform a correlated subquery?

老子叫甜甜 提交于 2019-12-07 13:35:40
问题 In How does PostgreSQL approach a 1 + n query?, I learned that a correlated subquery can be rewritten as a left join: select film_id, title, ( select array_agg(first_name) from actor inner join film_actor using(actor_id) where film_actor.film_id = film.film_id ) as actors from film order by title; to select f.film_id, f.title, array_agg(a.first_name) from film f left join film_actor fa using(film_id) left join actor a using(actor_id) group by f.film_id order by f.title; Bot queries return the

Inconsistent time zone conversion in PostgreSQL [duplicate]

女生的网名这么多〃 提交于 2019-12-02 07:22:09
问题 This question already has an answer here : Postgres UTC date format & epoch cast, sign inversion (1 answer) Closed last year . I'm attempting to select a local time (as at Australia/Brisbane) from a timestamptz field in a PostgreSQL database and noticed that when I use the +10 time zone abbreviation, PostgreSQL appears to subtract 10 hours from the UTC value instead of adding 10 hours. If I use AEST as the abbreviation, 10 hours are correctly added. When I run the following query I would

Recursive CTE concatenate fields with parents from arbitrary point

為{幸葍}努か 提交于 2019-12-02 07:09:03
问题 How can I concatenate a list of parent items in a RECURSIVE CTE with PostgreSQL (version 10.2)? For example, I have: CREATE TABLE test ( id SERIAL UNIQUE, parent integer references test(id), text text NOT NULL ); with: INSERT INTO test(parent, text) VALUES (NULL, 'first'), (1, 'second'), (2, 'third'), (3, 'fourth'), (NULL, 'top'), (5, 'middle'), (6, 'bottom'); How do I get a tree with a particular item and all it's parents concatenated (or in an array) given it's id? So far I have the

Recursive CTE concatenate fields with parents from arbitrary point

我们两清 提交于 2019-12-02 05:46:52
How can I concatenate a list of parent items in a RECURSIVE CTE with PostgreSQL (version 10.2)? For example, I have: CREATE TABLE test ( id SERIAL UNIQUE, parent integer references test(id), text text NOT NULL ); with: INSERT INTO test(parent, text) VALUES (NULL, 'first'), (1, 'second'), (2, 'third'), (3, 'fourth'), (NULL, 'top'), (5, 'middle'), (6, 'bottom'); How do I get a tree with a particular item and all it's parents concatenated (or in an array) given it's id? So far I have the following query to see what is being returned, but I can't seem to add the right WHERE clause to return the

Constructing a string out of several records with 2 columns

半世苍凉 提交于 2019-12-02 04:27:14
问题 I have prepared a simple SQL Fiddle for my question - In a word game written in Pl/pgSQL for PostgreSQL 10.2 player moves are stored in the table: CREATE TABLE words_scores ( mid bigint NOT NULL REFERENCES words_moves ON DELETE CASCADE, gid integer NOT NULL REFERENCES words_games ON DELETE CASCADE, uid integer NOT NULL REFERENCES words_users ON DELETE CASCADE, word text NOT NULL CHECK(word ~ '^[A-Z]{2,}$'), score integer NOT NULL CHECK(score >= 0) ); Here it is filled with some test data:

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

倾然丶 夕夏残阳落幕 提交于 2019-12-01 10:38:06
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 further detail this time - hopefully it will help pinpoint the issue: PG version 10.7 (running on heroku

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

混江龙づ霸主 提交于 2019-11-29 18:16:35
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 based on state code 2 from the state's main table. The state short name is 'ab' for state code 2 so

How to partition postgres table using intermediate table

ぐ巨炮叔叔 提交于 2019-11-28 14:45:19
I am using postgres 10 db. I am having Customers table consisting of following columns custid (primary key), name, phonenumber, email, dateofbirth, address, city, country, status(boolean) Join_Date(Date) I have million of records in table. I want to partition table based on different months(Jan 2018 one partition, Feb 2018 one partition,..etc) by help of Join_Date and with help of Intermediate table. I also want to write the automated script such that at the end of month the table have to get create another partition of last month Try this method: First of all, create an additional column in