Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
All versions of PostgreSQL. Add an additional version-specific tag like [postgresql-13] if that context is relevant.
0
votes
1
answer
90
views
How to get users how do not have a group (through join table)?
I want to get users how are not present in a group. The group name is "everybody".
I have a join table called groups_users with user_id and group_id.
I did this
SELECT users.email
FROM users
WHE …
6
votes
1
answer
2k
views
What happens if data gets inserted in the middle of a transaction?
I'm new to database and I'm lost with transaction. For example
in a situation where I have a table sensor_log that receives INSERT constantly and I want to move data to two other tables in one transac …
0
votes
1
answer
176
views
Sum on distinct and group by and filtering
This is the next version of Sum on distinct and group by
But It goes deeper
I have this :
CREATE TABLE active_connections(id serial PRIMARY KEY, source text NOT NULL, user_id int NOT NULL);
INSERT …
1
vote
0
answers
32
views
How to avoid slow queries when mixing ANY and ORDER + LIMIT?
I am wondering how could I prevent this to happen and why PostgreSQL is not able to handle it by itself? …
1
vote
1
answer
293
views
Count specific query occurred in Redshift
I wanted to count the number queries executed over one day. I have this working version :
SELECT DATE_TRUNC('day', starttime) AS date,
COUNT(*) AS COUNT
FROM stl_query
WHERE querytxt LIKE 'CO …
0
votes
0
answers
57
views
Concurent DELETE with condition
I am using PostgreSQL 10 …
13
votes
3
answers
16k
views
Get percentage of group by
I have this data:
CREATE TABLE tickets(user_id int NOT NULL);
INSERT INTO tickets VALUES (1);
INSERT INTO tickets VALUES (2);
INSERT INTO tickets VALUES (3); -- 3 times
INSERT INTO tickets VALUES (4); …
0
votes
2
answers
7k
views
Sum on distinct and group by
I have this :
CREATE TABLE tickets(id serial PRIMARY KEY, source text NOT NULL, user_id int NOT NULL, shop_id int NOT NULL, created_at time DEFAULT current_time);
INSERT INTO tickets VALUES (0, 'web- …
0
votes
1
answer
84
views
How to use document age as weigt in ts_rank
In a search mode I would like to impact the rank of my search related to age of the document. I have a working version but I found it very complicated.
It say "Does the same founded younger document …
3
votes
0
answers
777
views
How to iterate over an array of strings and returns matching word
I'm testing text search on PostgreSQL and I would like to search for multiple terms based on a custom dictionnary
I have :
CREATE TABLE events (name text NOT NULL, description text NOT NULL);
INSERT …
0
votes
2
answers
1k
views
How to simulate FOR UPDATE lock on UPDATE on PostgreSQL?
I am trying to play with PostgreSQL 14 and row level lock on update. …
2
votes
2
answers
3k
views
Search on concatenate columns
I have this :
CREATE TABLE users
(
first_name varchar(60) NOT NULL,
last_name varchar(60) NOT NULL
);
INSERT INTO users
(first_name, last_name)
VALUES
('Sylvia ', 'Hoeks'),
('Ha …
3
votes
2
answers
116
views
Avoid duplication when using other table in WHERE and JOIN clause in Postgres
I have 3 tables (devices, shops, device_shops_versions). devices can have many device_shops_versions.
device_shops_versions table:
+----+---------+-----------+---------+---------------------------+
…
0
votes
2
answers
1k
views
Add array table constraints, empty or null if other column is false
I'm adding constraint on an existing table jobs:
DROP TABLE IF EXISTS jobs CASCADE;
DROP TYPE IF EXISTS job_state;
CREATE TYPE job_state AS ENUM ( 'UNSTARTED', 'STARTED', 'FAILED', 'COMPLETED' );
CRE …
1
vote
Accepted
Add array table constraints, empty or null if other column is false
The constraint should be written using an OR like (NOT A) OR B
ALTER TABLE jobs
ADD CONSTRAINT error_message_is_null_if_failed_is_false
CHECK ( NOT ( status IN ('UNSTARTED', 'STARTED', 'COMPLETED …