postgresql

Django Full Text Search Optimization - Postgres

五迷三道 提交于 2021-01-21 04:30:11
问题 I am trying to create a Full Text Search for an address autocomplete feature, leveraging Django (v2.1) and Postgres (9.5), but the performance is not suitable for an auto-complete at the moment and I don't get the logic behind the performance results I get. For info the table is quite sizeable, with 14 million rows. My model: from django.db import models from postgres_copy import CopyManager from django.contrib.postgres.indexes import GinIndex class Addresses(models.Model): date_update =

Update lower/upper bound of range type

给你一囗甜甜゛ 提交于 2021-01-20 19:43:11
问题 I have column of tstzrange type (timestamp with time zone range) and I need to update only upper or lower bound of this value (and keep inclusive/exclusive boundaries) I managed to change (-infinity,infinity) with UPDATE table SET my_column = tstzrange( lower(my_column), now(), '()' ) and I have (-infinity, <current timestamp>) but I don't know how to keep boundaries from default range.. this would change even [ ] to ( ) 回答1: I found function I missed, it's possible to do that like this

Update lower/upper bound of range type

ⅰ亾dé卋堺 提交于 2021-01-20 19:41:32
问题 I have column of tstzrange type (timestamp with time zone range) and I need to update only upper or lower bound of this value (and keep inclusive/exclusive boundaries) I managed to change (-infinity,infinity) with UPDATE table SET my_column = tstzrange( lower(my_column), now(), '()' ) and I have (-infinity, <current timestamp>) but I don't know how to keep boundaries from default range.. this would change even [ ] to ( ) 回答1: I found function I missed, it's possible to do that like this

How to encrypt a column in Postgres using Hibernate @ColumnTransformer

穿精又带淫゛_ 提交于 2021-01-20 19:25:55
问题 I am trying to encrypt a column in my prostrgres DB. The column name is "test" of type "bytea". My enity code is below, @ColumnTransformer( forColumn="test", read="pgp_sym_encrypt(test::bytea, 'mySecretKey')", write="pgp_sym_decrypt(?, 'mySecretKey')") private String test; When I tried to retrieve the entity, I am getting the encrypted data like below. How do I get the decrypted value programmatically? But I get the actual value If i execute a postgres select query. "test": "\

How to encrypt a column in Postgres using Hibernate @ColumnTransformer

北战南征 提交于 2021-01-20 19:22:02
问题 I am trying to encrypt a column in my prostrgres DB. The column name is "test" of type "bytea". My enity code is below, @ColumnTransformer( forColumn="test", read="pgp_sym_encrypt(test::bytea, 'mySecretKey')", write="pgp_sym_decrypt(?, 'mySecretKey')") private String test; When I tried to retrieve the entity, I am getting the encrypted data like below. How do I get the decrypted value programmatically? But I get the actual value If i execute a postgres select query. "test": "\

How to encrypt a column in Postgres using Hibernate @ColumnTransformer

北城余情 提交于 2021-01-20 19:21:00
问题 I am trying to encrypt a column in my prostrgres DB. The column name is "test" of type "bytea". My enity code is below, @ColumnTransformer( forColumn="test", read="pgp_sym_encrypt(test::bytea, 'mySecretKey')", write="pgp_sym_decrypt(?, 'mySecretKey')") private String test; When I tried to retrieve the entity, I am getting the encrypted data like below. How do I get the decrypted value programmatically? But I get the actual value If i execute a postgres select query. "test": "\

PostgreSQL , Select from 2 tables, but only the latest element from table 2

不想你离开。 提交于 2021-01-20 19:09:27
问题 Hey, I have 2 tables in PostgreSql: 1 - documents: id, title 2 - updates: id, document_id, date and some data: documents: | 1 | Test Title | updates: | 1 | 1 | 2006-01-01 | | 2 | 1 | 2007-01-01 | | 3 | 1 | 2008-01-01 | So All updates are pointing to the same document, but all with different dates for the updates. What I am trying to do is to do a select from the documents table, but also include the latest update based on the date. How should a query like this look like? This is the one I

PostgreSQL , Select from 2 tables, but only the latest element from table 2

◇◆丶佛笑我妖孽 提交于 2021-01-20 19:08:32
问题 Hey, I have 2 tables in PostgreSql: 1 - documents: id, title 2 - updates: id, document_id, date and some data: documents: | 1 | Test Title | updates: | 1 | 1 | 2006-01-01 | | 2 | 1 | 2007-01-01 | | 3 | 1 | 2008-01-01 | So All updates are pointing to the same document, but all with different dates for the updates. What I am trying to do is to do a select from the documents table, but also include the latest update based on the date. How should a query like this look like? This is the one I

PostgreSQL , Select from 2 tables, but only the latest element from table 2

£可爱£侵袭症+ 提交于 2021-01-20 19:05:21
问题 Hey, I have 2 tables in PostgreSql: 1 - documents: id, title 2 - updates: id, document_id, date and some data: documents: | 1 | Test Title | updates: | 1 | 1 | 2006-01-01 | | 2 | 1 | 2007-01-01 | | 3 | 1 | 2008-01-01 | So All updates are pointing to the same document, but all with different dates for the updates. What I am trying to do is to do a select from the documents table, but also include the latest update based on the date. How should a query like this look like? This is the one I

Have “select for update” block on nonrexisting rows

五迷三道 提交于 2021-01-20 18:59:57
问题 we have some persistent data in an application, that is queried from a server and then stored in a database so we can keep track of additional information. Because we do not want to query when an object is used in the memory we do an select for update so that other threads that want to get the same data will be blocked. I am not sure how select for update handles non-existing rows. If the row does not exist and another thread tries to do another select for update on the same row, will this