postgresql

How to improve speed of query?

随声附和 提交于 2021-01-29 12:21:04
问题 I have got next table with data: CREATE TABLE xml_files ( "parsing_status" Character Varying( 150 ), "purchaseNumber" Character Varying( 2044 ), "docPublishDate" Timestamp With Time Zone ); ; data: purchaseNumber parsing_status docPublishDate 0373200554017000226 null 2017-07-28 19:00:10.885+03 0373200554017000226 null 2017-07-28 19:08:30.346+03 0373200554017000226 null 2017-07-28 19:24:35.265+03 0373400005317002182 null 2017-07-28 19:45:02.162+03 0348100035117000082 null 2017-07-28 20:08:26

peewee - change schema dynamically

半世苍凉 提交于 2021-01-29 11:14:13
问题 I have the same question/problem than this post -> peewee - modify db model meta (e.g. schema) dynamically . I want to change the schema field in my Meta class dynamically. This is my code: class GPSPosition(Model): def __init__(self, esquema, vehiculo, fechaFrom): self.esquema = esquema + '_org' self.vehiculo = vehiculo self.fechaFrom = fechaFrom orgid = BigIntegerField() id = BigIntegerField() vehicleid = BigIntegerField() driverid = BigIntegerField() originaldriverid = BigIntegerField(null

Removing repeated letters in a set of rows on PostgreSQL 8.3

不羁岁月 提交于 2021-01-29 10:49:01
问题 I have a query that returns a set of rows with a combination of the letters A , E , I and L . That combination are Portuguese mneumonics for Alterar , Excluir , Incluir , and Listar . The column value can vary between A , AE , AEL , AELI ... L , LI , LIA , LIAE . In the example illustrated below I would like to be able to get a unique string with all repeated letters removed. So the result would be AELI , a merge of all rows. My first attempt was using the combination of the functions array

Postgresql TRIGGER shows incorrect NEW value

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 10:17:31
问题 I am making a trigger for a user table that to hash password before inserting or updating password. However, for a reason I ignore, when I insert a new row, NEW.password is null for the trigger. CREATE EXTENSION IF NOT EXISTS pgcrypto; DROP TABLE IF EXISTS public.user; DROP TRIGGER IF EXISTS encrypt_user_password ON public.user; DROP DOMAIN IF EXISTS public.email_adress; DROP TYPE IF EXISTS public.user_role; DROP FUNCTION IF EXISTS encrypt_password; CREATE TYPE user_role AS ENUM ('user',

Postgresql Function with optional parameters

£可爱£侵袭症+ 提交于 2021-01-29 09:59:56
问题 Is there a way to create a function which can be called with a variable number of parameters (comma separated, so positional). For example, calling a such function with function1(param1,param2) and possibly calling it with function1(,param2) or function1(param1,) ? I've created a function with default parameters but I've errors when calling it : select * from iDxi('3 days',) order by "Date" asc ERROR: syntax error at or near ")" LINE 1: select * from iDxi('3 days',) order by "Date" asc My

ERROR: extra data after last expected column in Postgres

怎甘沉沦 提交于 2021-01-29 09:55:39
问题 I have a json file as: [xyz@innolx20122 ~]$ cat test_cgs.json {"technology":"AAA","vendor":"XXX","name":"RBNI","temporal_unit":"hour","regional_unit":"cell","dataset_metadata":"{\"name\": \"RBNI\", \"intervals_epoch_seconds\": [[1609941600, 1609945200]], \"identifier_column_names\": [\"CELLID\", \"CELLNAME\", \"NETWORK\"], \"vendor\": \"XXX\", \"timestamp_column_name\": \"COLLECTTIME\", \"regional_unit\": \"cell\"}","rk":1} which I am trying to upload to below table in Postgres CREATE TABLE

Postgres: drop foreign key constraint query getting stuck

北慕城南 提交于 2021-01-29 09:52:17
问题 I wanted to remove all foreign key constraints from a schema. I was successful in dropping constraints from most of the tables but in few of them drop foreign key constraint query is getting stuck. ALTER TABLE table_name DROP CONSTRAINT fkey_name; I tried truncate cascade but it was also getting stuck. I deleted all rows from both the tables manually. Still getting stuck. Edits: By getting stuck I mean query continues running for long time without any error message even though tables are

Function to select column values by comparing against comma separated list

谁说我不能喝 提交于 2021-01-29 09:49:21
问题 I want to compare my comma delimited string with column values. I did the following, which is not returning the expected result. ll = '"Java,CPP"' is coming dynamically. create or replace function testing(ll text) returns void as $body$ Declare foo text[]; ko text[]; BEGIN select unique_code into foo from codings where unique_code = ANY (regexp_split_to_array(ll, '\,')); raise info '%',foo; END; $body$ Language plpgsql; I got below error ERROR: column "Java,CPP" does not exist LINE 1: SELECT

How to ignore SequelizeUniqueConstraintError in Sequelize?

有些话、适合烂在心里 提交于 2021-01-29 09:47:27
问题 Using the example from the documentation, everything works well only at the first insertion. After the second and subsequent, errors appear. const Product = this.sequelize.define('Product', { title: Sequelize.STRING }); const Tag = this.sequelize.define('Tag', { name: Sequelize.STRING, unique: true }); const ProductTag = this.sequelize.define('ProductTag', { product_id: Sequelize.INTEGER, tag_id: Sequelize.INTEGER }); Product.belongsToMany(Tag, {through: 'ProductTag', as: 'tag'}); Tag

Is it possible to rebuild pg_depend?

自闭症网瘾萝莉.ら 提交于 2021-01-29 09:31:14
问题 I have a PostgreSQL 9.4 database affected by the following bug in BDR: https://github.com/2ndQuadrant/bdr/issues/309 In a nutshell, that bug in BDR resulted in missing dependencies in the pg_depend system catalog. Now when I use pg_dump , objects are dumped out of order and the dump can't be used without manual editing. Is there a way to make PostgreSQL rebuild the dependencies in pg_depend without rebuilding the database from scratch? 回答1: No, because that information is not redundant (that