postgresql-9.6

YYYY-MM column type in PostgreSQL

和自甴很熟 提交于 2020-11-29 08:18:14
问题 I need to a value associated to a month and a user in a table. And I want to perform queries on it. I don't know if there is a column data type for this type of need. If not, should I: Create a string field and build year-month concatenation (2017-01) Create a int field and build year-month concatenation (201701) Create two columns (one year and one month) Create a date column at the beginning of the month (2017-01-01 00:00:00) Something else? The objective is to run queries like (pseudo-SQL)

AWS RDS PostgreSQL access to pg_catalog.pg_authid forbidden in all contexts?

北慕城南 提交于 2020-07-03 10:18:52
问题 PostgreSQL said: permission denied for relation pg_authid Is pg_authid just unavailable on AWS RDS in all contexts because of RDS locking down the super role? My role created the table, so pg_catalog should come by default (and not need to be added to search path) if I'm reading psql docs right. Just need SELECT , not create ability. Haven't been able to find a definitive AWS RDS documentation page where it says that pg_catalog.pg_authid is not allowed in any context, but I've inherited a

Planner not using index order to sort the records using CTE

五迷三道 提交于 2020-06-28 06:13:11
问题 I am trying to pass some ids into an in-clause on a sorted index with the same order by condition but the query planner is explicitly sorting the data after performing index search. below are my queries. Generate a temporary table. SELECT a.n/20 as n, md5(a.n::TEXT) as b INTO temp_table From generate_series(1, 100000) as a(n); create an index CREATE INDEX idx_temp_table ON temp_table(n ASC, b ASC); In below query, planner uses index ordering and doesn't explicitly sorts the data.(expected)

Postgres error after updating TimescaleDB on Ubuntu: file not found

元气小坏坏 提交于 2020-06-23 04:33:19
问题 As specified in the official docs I added the Timescale PPA repository to apt . I then installed it via sudo apt install timescaledb-postgresql-9.6 . All was working fine. With a recent run of sudo apt upgrade the timescale package got updated from 0.8.0~ubuntu16.04 to 0.9.1~ubuntu16.04 . When running my Python script for inserting some new data I now get the following error (and nothing is being inserted): 2018-04-12 09:42:06,279 ERROR Postgres: could not access file "timescaledb-0.8.0": No

Locate popular strings with PostgreSQL

余生长醉 提交于 2020-05-11 02:57:32
问题 I have a bunch of text rows in a PostgreSQL table and I am trying to find common strings. For example, let's say I have a basic table like: CREATE TABLE a (id serial, value text); INSERT INTO a (value) VALUES ('I go to the movie theater'), ('New movie theater releases'), ('Coming out this week at your local movie theater'), ('New exposition about learning disabilities at the children museum'), ('The genius found in learning disabilities') ; I am trying to locate popular strings like movie

Locate popular strings with PostgreSQL

无人久伴 提交于 2020-05-11 02:57:19
问题 I have a bunch of text rows in a PostgreSQL table and I am trying to find common strings. For example, let's say I have a basic table like: CREATE TABLE a (id serial, value text); INSERT INTO a (value) VALUES ('I go to the movie theater'), ('New movie theater releases'), ('Coming out this week at your local movie theater'), ('New exposition about learning disabilities at the children museum'), ('The genius found in learning disabilities') ; I am trying to locate popular strings like movie

Best way to get distinct count from a query joining two tables (multiple join possibilities)

巧了我就是萌 提交于 2020-04-18 05:48:05
问题 I have 2 tables, table Actions & table Users . Actions -> Users is many-one association. Table Actions (has thousands of rows) id uuid name type created_by org_id Table Users (has a max of hundred rows) id username org_id org_name I am trying to get the best join query to obtain a count with a WHERE clause. I need the count of distinct created_by s from table Actions with an org_name in Table Users that contains 'myorg'. Also, ( Actions.created_by = Users.username ) I currently have the below