Questions tagged [postgresql]

PostgreSQL is an open-source, relational database management system (RDBMS) available for all major platforms, including Linux, UNIX, Windows and OS X. Mention your version of Postgres when asking questions. Consider dba.stackexchange.com for questions concerning the administration or advanced features.

postgresql
Filter by
Sorted by
Tagged with
0 votes
2 answers
551 views

How to pass more then 100 arguments into postgresSQL function

[When passing more then 100 arguments into postgresql function getting error] ERROR: cannot pass more than 100 arguments to a function
Anonymous's user avatar
0 votes
1 answer
105 views

Issue while passing arrays to stored Function

trying to delete records by passing arrays into the stored function. testing=# select * from links; id | url | name | description | last_update ----+-----...
manikandan's user avatar
0 votes
1 answer
66 views

Optimize multiple case expressions with THEN/END

I have following query. SELECT i.id, CASE WHEN ia.detail_count = 1 THEN i.space_id ELSE NULL END AS space_id, CASE WHEN ia.detail_count = 1 THEN i.resident_id ELSE ...
user18435906's user avatar
0 votes
1 answer
46 views

PostgreSQL how to generate each Parent Product so as to have all the Child product (and Child of child) tied to them (the parent products)

This might look a little trivial to most PostgreSQL(or SQL) experts, but since I am fairly new to this, I'm having a little hard time coming up with a sound logical rule to solve this problem. The ...
Emmanuel A.'s user avatar
0 votes
1 answer
809 views

How to pass in password to pg_dump when using spring boot

I'm trying to make a backup of my Postgres database in Spring boot But I got this error: 2022-03-10 21:17:57.751 INFO 8132 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-...
qpdpQ's user avatar
  • 21
0 votes
1 answer
1k views

Django migration gives psycopg2.errors.DuplicateTable: relation error

I have previously restored the database for the system, and while i tried to migrate through the django applicaion, the following error is thrown. What is the possible cause and how can we mitigate ...
hillsonghimire's user avatar
0 votes
1 answer
1k views

Stored procedure in pgsql to create materialized views

I'm trying to create a stored procedure in pgsql that creates a materialized view with data from a specific year from a table. The parameters will be the table name, the column that contains the year, ...
Eulidio's user avatar
0 votes
2 answers
2k views

Seek Pagination with Knex library for Postgress

Attempting to implement cursor based pagination - and I would like to know the proper way to call it with Knex for Postgres. Here is the standard statement: SELECT FROM WHERE (timestamp, id) > (...
Edv Beq's user avatar
  • 936
0 votes
1 answer
803 views

error: could not load library ~ undefined symbol: errcontext

First, I installed oracle_fdw and oracle instant client. Second, I set LD_LIBRARY_PATH and ORACLE_HOME (~/.bash_profile). Finally, I ran the make command in the oracle_fdw directory. I installed the ...
서 민진's user avatar
0 votes
2 answers
336 views

SELECT DISTINCT to return at most one row

Given the following db structure: Regions id name 1 EU 2 US 3 SEA Customers: id name region 1 peter 1 2 henry 1 3 john 2 There is also a PL/pgSQL function in place, defined as sendShipment() ...
ptye's user avatar
  • 21
0 votes
1 answer
1k views

select values of a column based on values of another column

I have a table: ID, color ---- ------ 1 red 2 red 3 green 4 green 5 green 6 blue 7 blue Desired result of the query: red 1,2 green 3,4,5 blue 6,...
techie11's user avatar
  • 1,291
0 votes
1 answer
96 views

Postgres constraint for a subset of rows

I have a Postgres table containing tasks (tasks). A task can link to many entities using a link table (links). Tasks can be one of many types. A subset of tasks, denoted by their types (let's call it ...
Nimrod Sadeh's user avatar
0 votes
1 answer
319 views

postgres plpgsql how to properly convert function to use FORMAT in DECLARE

I am writing a function in POSTGRES v13.3 that when passed an array of column names returns an array of JSONB objects each with the distinct values of one of the columns. I have an existing script ...
MikeB2019x's user avatar
0 votes
1 answer
395 views

Count on a column with a conditional statement in SQL?

I want a table as this: cycle_end_date | count(user_id) | count(repaid_user_id) | event_ts | repayment_ts 15th Jan | 20 | 15 | 23rd Jan | 25th Jan 15th Jan ...
coder_bg's user avatar
  • 370
0 votes
1 answer
25 views

Return the first and last value from one column when value from another column changes

I am trying to write a PostgreSQL query to return the first and last dates corresponding to indices. I have a table: Datetime Index March 1 2021 0 March 2 2021 0 March 3 2021 0 March 4 2021 1 ...
Rui Nian's user avatar
  • 2,699
0 votes
1 answer
229 views

Postgres query performance is damaged when adding a simple OR clause

An app that I'm working with runs a query like this: SELECT "categories"."id" FROM "categories" WHERE ( ('f' ) OR categories.id NOT IN ( ...
Brian K's user avatar
  • 621
0 votes
1 answer
96 views

postgresql query how to append dups counter to name column

I have table here. how to find all duplicate records, considering length(name)=3 ? and append dups counter to the name as a suffix? Below screenshot, Key 6 and 7 has characters length > 3 and when ...
Hari's user avatar
  • 313
0 votes
1 answer
148 views

Passing table name as an argument in PostGIS function

How can I pass my table name as an argument of a function? CREATE OR REPLACE FUNCTION public.countries_name1( z integer, x integer , y integer, name_prefix text default 'B' ) RETURNS bytea ...
DARK's user avatar
  • 13
0 votes
0 answers
256 views

Postgres: Exporting from public schema and importing into another schema

In postgres database, Is it possible to export data tables from public schema and import into another schema. I have having error while following the regular way of export and import. Regards Xian
x-zian's user avatar
  • 1
0 votes
1 answer
807 views

Count records for each day between the startdate and enddate in sequelize ORM (Performing this query in nodejs)

I am passing start_time and end_time as a query parameter in an API and want to have count of the records on each day from start_time and end_time. It is giving me total count of records between the ...
Jigyasa Chotwani's user avatar
2 votes
1 answer
139 views

Why Can't Haskell Separate PosgreSQL String into Fields?

I am new to PostgreSQL.Simple so please forgive if question is dumb. I am going through this tutorial: Postgresql Data Access with Haskell I got the first demo program to run. Now I am taking this ...
James Strieter's user avatar
0 votes
1 answer
80 views

I want to be able to access a particular key within a json object response returned in postgres using node js and express

The code :- app.post('/BSK', urlencodedParser, function(req, res){ client.query(Select * from public."mst_bskServices" where "Name" = '${req.body.Service}', (err, result)=>{ if(!...
Swarnabho Biswas Mac's user avatar
0 votes
2 answers
906 views

pg_largeobject huge, but no tables have OID column type

postrgresql noob, PG 9.4.x, no access to application code, developers, anyone knowledgeable about it User database CT has 427GB pg_largeobject (PGLOB) table, next largest table is 500ish MB. Per this ...
TheSQLGuru's user avatar
-1 votes
2 answers
36 views

Filter value from many columns in table

I trying to create SQL question to my PostgreSQL database. I have table looks like as: id | column1 | column2| column3 | column4 1 | 1 | 2 | 3 | 1 2 | 21 | 22 | 23 | ...
kiker's user avatar
  • 27
0 votes
1 answer
114 views

Cygnus does not persist data into PostSQL

I am using the following tutorial to persist data in a PostGresQL database via Cygnus. https://documenter.getpostman.com/view/513743/RWEcR2DC When using a MySQL database with Cygnus everything works ...
Yannick's user avatar
  • 69
4 votes
0 answers
2k views

Postgresql Incremental Materialized View Maintenance (IVM) challenges, why delay it again to targetversion 16? [closed]

The latest message from the commit fest https://wiki.postgresql.org/wiki/Incremental_View_Maintenance#CommitFest is saying "Changed targetversion to 16" so it seems this feature will not ...
acristu's user avatar
  • 741
0 votes
1 answer
266 views

Check if pg_prepare was already executed

Is there a way to check if pg_prepare already executed and remove it from the session? Seems like pg_close doesn't remove prepared statement from the session. Kind of seems like a bug in php, but ...
Nux's user avatar
  • 9,643
0 votes
1 answer
1k views

Create nested json in postgresql

I'm trying to create JSON object by passing to json_object() two arrays. One with keys, second with JSON(or JSONB) objects. So as to put JSON as value for predefined key. The signature of json_object()...
Andrey Kapliev's user avatar
2 votes
1 answer
334 views

Why pg_restore has modified a database not specified in the command?

I did a backup with pg_dump of a database called database_a (whose PostgreSQL owner was ubuntu) in the server A. I called database_a_bkp.dump to the resultant file. Afterwards, I went to other server ...
forvas's user avatar
  • 9,963
5 votes
2 answers
4k views

Why is pg_restore that slow and PostgreSQL almost not even using the CPU?

I just had to use pg_restore with a small dump of 30MB and it took in average 5 minutes! On my colleagues' computers, it is ultra fast, like a dozen of seconds. The difference between the two is the ...
eytienne's user avatar
  • 103
0 votes
1 answer
304 views

PostgreSQL double colon to Sequelize query

select column_name::date, count(*) from table_name group by column_name::date What is the equivalent of this SQL query in Sequelize? I couldn't find what to do when there is "double colon" ...
yalin's user avatar
  • 73
0 votes
0 answers
447 views

postgresql order by similarity (trigrams) on 2 fields

I used trigrams on 2 fields in my table and want to sort by MAX similarity comparing both fields during the request.(Postgresql 11.x) I have difficulties to do this: I can't use aliases in order by ...
alex.bour's user avatar
  • 2,874
0 votes
1 answer
339 views

Export big psql table to JSON

how i can export big table to json, but output file is over 1Gb copy (SELECT json_agg(export_data)::text FROM "table_name" export_data) TO '{{ path_name }}/{{ table_name }}.json' with csv ...
alex's user avatar
  • 1
0 votes
1 answer
712 views

How to solve error -2147467259 when querying large amounts of data in AZURE ML

I am trying to fetch a decent amount of data in Azure ML from a postgresql DB. When I limit the amount of data returned (e.g. LIMIT 100 000) the query executes as expected. However when I remove this ...
Tibo Geysen's user avatar
0 votes
1 answer
723 views

How to select aggregate discount percentages and flat amount?

I have a scenario whereby I need to aggregate n number of discounts to get a total discount. Each discount must be applied net of the previous discount. For example: I have an order of 200 Rs. (Sum of ...
Amrut Gaikwad's user avatar
0 votes
1 answer
2k views

Backup Postgres Table using pg_dump is there a workaround to include the --jobs option

I am using postgres 12 and have a database thats 1TB in size. I am performing a big delete on a table that is 140+GB in size. I am testing the process and am looking to do a pg_dump of the table and ...
rdbmsNoob's user avatar
  • 131
0 votes
1 answer
919 views

Creating point geometry from varchar (x,y)

I have a large table of locations. The locations are in varchar written as (x,y). I need to create a individual point for all of the locations. I have created a point geometry column in the table but ...
Ben Watson's user avatar
0 votes
0 answers
319 views

SQLAlchemy map function output to model

I'm using Python 3.5 Flask (0.12) SQLAlchemy (1.3.19) with postgres (12.9). I have sql function with int array parameter public.get_something(array[1,2,3,4,5]) which returns table with 15 fields. ...
Hawkridge's user avatar
4 votes
2 answers
1k views

Postgres Large table Optimal index selection for Select Query With In Clause

We have a very large table with a total number of rows around ~4 billion and everyday throughput is around ~20-25 million. Below is the Sample Table definition. table_name ( id bigint, user_id ...
Mohd Waseem's user avatar
  • 1,324
1 vote
0 answers
164 views

"failed: could not connect to server: Connection refused" in TravisCI

I use TravisCI to test pull requests, branches and mergers on GitHub, everything works fine until the last update (March 1, 2022), after that update I keep getting this error: DBIx::Class::Storage::...
Daniel Tanase's user avatar
0 votes
1 answer
703 views

Sequelize after creating new table insert default rows or execute sql file

I want to create new table countries with default rows. I am using sequelize with pg and I am wondering if there is a way to check if a table already exists if not execute a sql file. Also, I made a ...
Vitoo's user avatar
  • 21
0 votes
2 answers
256 views

How to shorten json data in Postgres?

So, I have a table (Using postgres v9) that has an id(integer) and a json(text). This is the query that I use to fetch it: select software_json from software_master where id=1; And I get { "...
Ritwik1711's user avatar
-1 votes
3 answers
81 views

Improve Postgresql queries selecting latest entries in groups

I have recorded events from multiple "users" into a single table, over years. Each user has a uid, a timestamp (when) and some other individual properties (e.g. version and language), ...
Thomas Tempelmann's user avatar
2 votes
1 answer
668 views

Connecting to postgresql from python 3, running in Cloud Shell: password authentication failed

I try to run locally (from GCP terminal) python 3 tutorial program to connect to my postgresql dsatabase. I run proxy, as it is suggested in source: ./cloud_sql_proxy -instances=xxxxxxxx:us-central1:...
IMozes's user avatar
  • 121
-1 votes
2 answers
76 views

SQL: select all depending nodes from a list of parent

let's take a table called users like this id name ... path 22 John ... 2/8/11/22/ 23 Mark ... 1/3/9/15/21/23/ where the path rapresents the hierarchy parent-child. Now, I have a list of "...
Fabio Manniti's user avatar
1 vote
0 answers
115 views

Getting error while uploading dataframe into pgadmin using to_postgis

I have a dataframe stations_gdf, and I want to upload this dataframe in pgAdmin, using the following code, but I am getting error, and I dont have anz idea how could I solve that :( Can anybody help ...
Nafisa Anjum Samia's user avatar
1 vote
0 answers
181 views

Getting different output of a function in different PG servers

I have migrated my database from postgres version 9.6 to postgres version 13, So I am facing a issue where a function returns different output in both the versions. I am explaining the problem with ...
Jay Godhani's user avatar
0 votes
1 answer
49 views

Postgresql: update data from dataframe python in spesific column table

i have table in my postgresql database with name "abc" id | name | age | hobby | address | status | 1 | ana | 32 | eat | NULL | NULL | 2 | mela | 43 | play | NULL | NULL | ...
Niken Amelia's user avatar
0 votes
2 answers
189 views

sql cast to str with zero after dot

How can i get '186.60' string from 186.6 number in sql ? select( 186.6::varchar); result is '186.6'
Ryabchenko Alexander's user avatar
0 votes
1 answer
121 views

POSTGRESQL: Join columns

I have a POSTGRESQL version 12.5 database where I have a table that has three columns: c_id, columna and columnb. The three columns can have a different values. I need to do a join their values into a ...
Melchia's user avatar
  • 23.5k

1
565 566
567
568 569
3524