question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
I am switching to PostgreSQL from SQLite for a typical Rails application. The problem is that running specs became slow with PG. On SQLite it took ~34 seconds, on PG it's ~76 seconds which is more than 2x slower. So now I want to apply some techniques to bring the performance of the specs on par with SQLite with no cod...
First, always use the latest version of PostgreSQL. Performance improvements are always coming, so you're probably wasting your time if you're tuning an old version. For example, PostgreSQL 9.2 significantly improves the speed of TRUNCATE and of course adds index-only scans. Even minor releases should always be followe...
PostgreSQL
9,407,442
254
Somehow I've managed to completely bugger the install of postgresql on Ubuntu karmic. I want to start over from scratch, but when I "purge" the package with apt-get it still leaves traces behind such that the reinstall configuration doesn't run properly. After I've done: apt-get purge postgresql apt-get install postgr...
Option A If your install isn't already damaged, you can drop unwanted PostgreSQL servers ("clusters") using pg_dropcluster. Use that in preference to a full purge and reinstall if you just want to restart with a fresh PostgreSQL instance. $ pg_lsclusters Ver Cluster Port Status Owner Data directory Log ...
PostgreSQL
2,748,607
254
Looking through the documentation for the Postgres 9.4 datatype JSONB, it is not immediately obvious to me how to do updates on JSONB columns. Documentation for JSONB types and functions: http://www.postgresql.org/docs/9.4/static/functions-json.html http://www.postgresql.org/docs/9.4/static/datatype-json.html As an exa...
If you're able to upgrade to Postgresql 9.5, the jsonb_set command is available, as others have mentioned. In each of the following SQL statements, I've omitted the where clause for brevity; obviously, you'd want to add that back. Update name: UPDATE test SET data = jsonb_set(data, '{name}', '"my-other-name"'); Replac...
PostgreSQL
26,703,476
253
So I have a in my Postgresql: TAG_TABLE ========================== id tag_name -------------------------- 1 aaa 2 bbb 3 ccc To simplify my problem, What I want to do is SELECT 'id' from TAG_TABLE when a string "aaaaaaaa" contains the 'tag_name'. So ideally, it sho...
You should use tag_name outside of quotes; then it's interpreted as a field of the record. Concatenate using '||' with the literal percent signs: SELECT id FROM TAG_TABLE WHERE 'aaaaaaaa' LIKE '%' || tag_name || '%'; And remember that LIKE is case-sensitive. If you need a case-insensitive comparison, you could do thi...
PostgreSQL
23,320,945
253
I just installed PostgreSQL with Homebrew and when I go on to type the command psql I get the following error: dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.2.dylib Referenced from: /usr/local/bin/psql Reason: image not found [1] 69711 trace trap psql What's wrong?
I was getting the exact same error, but the previous answers didn't work for me. I had to reinstall PostgreSQL. brew reinstall postgresql
PostgreSQL
21,488,778
253
Is email address a bad candidate for primary when compared to auto incrementing numbers? Our web application needs the email address to be unique in the system. So, I thought of using email address as primary key. However my colleague suggests that string comparison will be slower than integer comparison. Is it a val...
String comparison is slower than int comparison. However, this does not matter if you simply retrieve a user from the database using the e-mail address. It does matter if you have complex queries with multiple joins. If you store information about users in multiple tables, the foreign keys to the users table will be th...
PostgreSQL
3,804,108
251
When you are upserting a row (PostgreSQL >= 9.5), and you want the possible INSERT to be exactly the same as the possible UPDATE, you can write it like this: INSERT INTO tablename (id, username, password, level, email) VALUES (1, 'John', 'qwerty', 5, 'john@mail.com') ON CONFLICT (id) DO UPDATE SET ...
Postgres hasn't implemented an equivalent to INSERT OR REPLACE. From the ON CONFLICT docs (emphasis mine): It can be either DO NOTHING, or a DO UPDATE clause specifying the exact details of the UPDATE action to be performed in case of a conflict. Though it doesn't give you shorthand for replacement, ON CONFLICT DO UP...
PostgreSQL
36,359,440
247
I have a simple list of ~25 words. I have a varchar field in PostgreSQL, let's say that list is ['foo', 'bar', 'baz']. I want to find any row in my table that has any of those words. This will work, but I'd like something more elegant. select * from table where (lower(value) like '%foo%' or lower(value) like '%bar%' or...
PostgreSQL also supports full POSIX regular expressions: select * from table where value ~* 'foo|bar|baz'; The ~* is for a case insensitive match, ~ is case sensitive. Another option is to use ANY: select * from table where value like any (array['%foo%', '%bar%', '%baz%']); select * from table where value ilike any (...
PostgreSQL
4,928,054
247
Say I have an interval like 4 days 10:00:00 in postgres. How do I convert that to a number of hours (106 in this case?) Is there a function or should I bite the bullet and do something like extract(days, my_interval) * 24 + extract(hours, my_interval)
Probably the easiest way is: SELECT EXTRACT(epoch FROM my_interval)/3600
PostgreSQL
952,493
247
I am trying to create a database from command line. My OS is centos and postgres version is 10.9. sudo -u postgres psql createdb test Password for user test: Why is it prompting me for the password?
Change the user to postgres : su - postgres Create User for Postgres (in the shell and NOT with psql) $ createuser testuser Create Database (same) $ createdb testdb Acces the postgres Shell psql ( enter the password for postgressql) Provide the privileges to the postgres user $ alter user testuser with encrypted pa...
PostgreSQL
30,641,512
246
Question is simple. How to add column x to table y, but only when x column doesn't exist ? I found only solution here how to check if column exists. SELECT column_name FROM information_schema.columns WHERE table_name='x' and column_name='y';
With Postgres 9.6 this can be done using the option if not exists ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name INTEGER;
PostgreSQL
12,597,465
246
I'm working on the design for a RoR project for my company, and our development team has already run into a bit of a debate about the design, specifically the database. We have a model called Message that needs to be persisted. It's a very, very small model with only three db columns other than the id, however there wi...
Rows per a table won't be an issue on it's own. So roughly speaking 1 million rows a day for 90 days is 90 million rows. I see no reason Postgres can't deal with that, without knowing all the details of what you are doing. Depending on your data distribution you can use a mixture of indexes, filtered indexes, and table...
PostgreSQL
21,866,113
242
I have the following database table on a Postgres server: id date Product Sales 1245 01/04/2013 Toys 1000 1245 01/04/2013 Toys 2000 1231 01/02/2013 Bicycle 50000 456461 01/01/2014 Bananas 4546 I would like to create a query that gives the SUM of the Sales column and grou...
I can't believe the accepted answer has so many upvotes -- it's a horrible method. Here's the correct way to do it, with date_trunc: SELECT date_trunc('month', txn_date) AS txn_month, sum(amount) as monthly_sum FROM yourtable GROUP BY txn_month It's bad practice but you might be forgiven if you use GROUP BY ...
PostgreSQL
17,492,167
242
I'm trying to create a Postgres database for the first time. I assigned basic read-only permissions to the DB role that must access the database from my PHP scripts, and I have a curiosity: If I execute GRANT some_or_all_privileges ON ALL TABLES IN SCHEMA schema TO role; is there any need to also execute this? GRANT U...
GRANTs on different objects are separate. GRANTing on a database doesn't GRANT rights to the schema within. Similiarly, GRANTing on a schema doesn't grant rights on the tables within. If you have rights to SELECT from a table, but not the right to see it in the schema that contains it then you can't access the table. ...
PostgreSQL
17,338,621
241
I want the code to be able to automatically fill the timestamp value when a new row is inserted as I can do in MySQL using CURRENT_TIMESTAMP. How will I be able to achieve this in PostgreSQL? CREATE TABLE users ( id serial not null, firstname varchar(100), middlename varchar(100), lastname varchar(100),...
To populate the column during insert, use a DEFAULT value: CREATE TABLE users ( id serial not null, firstname varchar(100), middlename varchar(100), lastname varchar(100), email varchar(200), timestamp timestamp default current_timestamp ) Note that the value for that column can explicitly be overwritten b...
PostgreSQL
9,556,474
241
How do I delete an enum type value that I created in postgresql? create type admin_level1 as enum('classifier', 'moderator', 'god'); E.g. I want to remove moderator from the list. I can't seem to find anything on the docs. I'm using Postgresql 9.3.4.
You delete (drop) enum types like any other type, with DROP TYPE: DROP TYPE admin_level1; Is it possible you're actually asking about how to remove an individual value from an enum type? If so, you can't. It's not supported: Although enum types are primarily intended for static sets of values, there is support for a...
PostgreSQL
25,811,017
239
I want to create a database which does not exist through JDBC. Unlike MySQL, PostgreSQL does not support create if not exists syntax. What is the best way to accomplish this? The application does not know if the database exists or not. It should check and if the database exists it should be used. So it makes sense to c...
Restrictions You can ask the system catalog pg_database - accessible from any database in the same database cluster. The tricky part is that CREATE DATABASE can only be executed as a single statement. The manual: CREATE DATABASE cannot be executed inside a transaction block. So it cannot be run directly inside a func...
PostgreSQL
18,389,124
237
Seems like Money type is discouraged as described here. My application needs to store currency, which datatype shall I be using? Numeric, Money or FLOAT?
Your source is in no way official. It dates to 2011 and I don't even recognize the authors. If the money type was officially "discouraged" PostgreSQL would say so in the manual - which it doesn't. For a more official source, read this thread in pgsql-general (from just this week!), with statements from core developers ...
PostgreSQL
15,726,535
236
I'm trying to restore my dump file, but it caused an error: psql:psit.sql:27485: invalid command \N Is there a solution? I searched, but I didn't get a clear answer.
Postgres uses \N as substitute symbol for NULL value. But all psql commands start with a backslash \ symbol. You can get these messages, when a copy statement fails, but the loading of dump continues. This message is a false alarm. You have to search all lines prior to this error if you want to see the real reason why ...
PostgreSQL
20,427,689
235
I'm having a table like this Movie Actor A 1 A 2 A 3 B 4 I want to get the name of a movie and all actors in that movie, and I want the result to be in a format like this: Movie ActorList A 1, 2, 3 How can I do it?
Simpler with the aggregate function string_agg() (Postgres 9.0 or later): SELECT movie, string_agg(actor, ', ') AS actor_list FROM tbl GROUP BY 1; The 1 in GROUP BY 1 is a positional reference and a shortcut for GROUP BY movie in this case. string_agg() expects data type text as input. Other types need to be cast e...
PostgreSQL
15,847,173
235
I have a question about the ALTER TABLE command on a really large table (almost 30 millions rows). One of its columns is a varchar(255) and I would like to resize it to a varchar(40). Basically, I would like to change my column by running the following command: ALTER TABLE mytable ALTER COLUMN mycolumn TYPE varchar(40)...
In PostgreSQL 9.1 there is an easier way http://www.postgresql.org/message-id/162867790801110710g3c686010qcdd852e721e7a559@mail.gmail.com CREATE TABLE foog(a varchar(10)); ALTER TABLE foog ALTER COLUMN a TYPE varchar(30); postgres=# \d foog Table "public.foog" Column | Type | Modifiers --------+--...
PostgreSQL
7,729,287
235
Is it possible? Can i specify it on the connection URL? How to do that?
I know this was answered already, but I just ran into the same issue trying to specify the schema to use for the liquibase command line. Update As of JDBC v9.4 you can specify the url with the new currentSchema parameter like so: jdbc:postgresql://localhost:5432/mydatabase?currentSchema=myschema Appears based on an e...
PostgreSQL
4,168,689
235
I'm using the PostgreSQL database for my Ruby on Rails application (on Mac OS X 10.9). Are there any detailed instructions on how to upgrade PostgreSQL database? I'm afraid I will destroy the data in the database or mess it up.
Assuming you've used home-brew to install and upgrade Postgres, you can perform the following steps. Stop current Postgres server: launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist Initialize a new 10.1 database: initdb /usr/local/var/postgres10.1 -E utf8 run pg_upgrade (note: change bin version i...
PostgreSQL
24,379,373
233
Postgres 8.4 and greater databases contain common tables in public schema and company specific tables in company schema. company schema names always start with 'company' and end with the company number. So there may be schemas like: public company1 company2 company3 ... companynn An application always works with a sin...
It depends on what you want to test exactly. Information schema? To find "whether the table exists" (no matter who's asking), querying the information schema (information_schema.tables) is incorrect, strictly speaking, because (per documentation): Only those tables and views are shown that the current user has access ...
PostgreSQL
20,582,500
233
After this comment to one of my questions, I'm thinking if it is better using one database with X schemas or vice versa. I'm developing a web application where, when people register, I create (actually) a database (no, it's not a social network: everyone must have access to his own data and never see the data of the ot...
A PostgreSQL "schema" is roughly the same as a MySQL "database". Having many databases on a PostgreSQL installation can get problematic; having many schemas will work with no trouble. So you definitely want to go with one database and multiple schemas within that database.
PostgreSQL
1,152,405
232
How can I find out which version of PostGIS I have?
Since some of the functions depend on other libraries like GEOS and proj4 you might want to get their versions too. Then use: SELECT PostGIS_full_version();
PostgreSQL
4,833,282
231
I can't find a definite answer to this question in the documentation. If a column is an array type, will all the entered values be individually indexed? I created a simple table with one int[] column, and put a unique index on it. I noticed that I couldn't add the same array of ints, which leads me to believe the index...
Yes you can index an array, but you have to use the array operators and the GIN-index type. Example: CREATE TABLE "Test"("Column1" int[]); INSERT INTO "Test" VALUES ('{10, 15, 20}'); INSERT INTO "Test" VALUES ('{10, 20, 30}'); CREATE INDEX idx_test on "Test" USING GIN ("Column1" gin__int_ops); ...
PostgreSQL
4,058,731
231
I'm trying to test out the json type in PostgreSQL 9.3. I have a json column called data in a table called reports. The JSON looks something like this: { "objects": [ {"src":"foo.png"}, {"src":"bar.png"} ], "background":"background.png" } I would like to query the table for all reports that match the 'sr...
jsonb in Postgres 9.4+ You can use the same query as for 9.3+ below, just with jsonb_array_elements(). But you should rather use the jsonb "contains" operator @> in combination with a matching GIN index on the expression data->'objects': CREATE INDEX reports_data_gin_idx ON reports USING gin ((data->'objects') jsonb_pa...
PostgreSQL
22,736,742
230
when i create a new user, but it cannot login the database. I do that like this: postgres@Aspire:/home/XXX$ createuser dev Shall the new role be a superuser? (y/n) n Shall the new role be allowed to create databases? (y/n) y Shall the new role be allowed to create more new roles? (y/n) y then create a database: post...
Try: psql -U user_name -h 127.0.0.1 -d db_name where -U is the database user name -h is the hostname/IP of the local server, thus avoiding Unix domain sockets -d is the database name to connect to This is then evaluated as a "network" connection by Postgresql rather than a Unix domain socket connection, thus not ev...
PostgreSQL
17,443,379
230
I'm using the official Postgres Docker image, trying to customize its configuration. For this purpose, I use the command sed to change max_connections for example: sed -i -e"s/^max_connections = 100.*$/max_connections = 1000/" /var/lib/postgresql/data/postgresql.conf I tried two methods to apply this configuration: T...
With Docker Compose When working with Docker Compose, you can use command: postgres -c option=value in your docker-compose.yml to configure Postgres. Adapting Vojtech Vitek's answer, you can use command: postgres -c config_file=/etc/postgresql.conf to change the config file Postgres will use. As per the comment by joh...
PostgreSQL
30,848,670
229
How do I write an SQL script to create a ROLE in PostgreSQL 9.1, but without raising an error if it already exists? The current script simply has: CREATE ROLE my_user LOGIN PASSWORD 'my_password'; This fails if the user already exists. I'd like something like: IF NOT EXISTS (SELECT * FROM pg_user WHERE username = 'my_...
Simple script (question asked) Building on @a_horse_with_no_name's answer and improved with @Gregory's comment: DO $do$ BEGIN IF EXISTS ( SELECT FROM pg_catalog.pg_roles WHERE rolname = 'my_user') THEN RAISE NOTICE 'Role "my_user" already exists. Skipping.'; ELSE CREATE ROLE my_user LOGI...
PostgreSQL
8,092,086
229
Which of the following two is more accurate? select numbackends from pg_stat_database; select count(*) from pg_stat_activity;
Those two queries aren't equivalent. The equivalent version of the first one would be: SELECT sum(numbackends) FROM pg_stat_database; In that case, I would expect that version to be slightly faster than the second one, simply because it has fewer rows to count. But you are not likely going to be able to measure a diff...
PostgreSQL
5,267,715
227
I regularly need to delete all the data from my PostgreSQL database before a rebuild. How would I do this directly in SQL? At the moment I've managed to come up with a SQL statement that returns all the commands I need to execute: SELECT 'TRUNCATE TABLE ' || tablename || ';' FROM pg_tables WHERE tableowner='MYUSER'; ...
FrustratedWithFormsDesigner is correct, PL/pgSQL can do this. Here's the script: CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$ DECLARE statements CURSOR FOR SELECT tablename FROM pg_tables WHERE tableowner = username AND schemaname = 'public'; BEGIN FOR stmt ...
PostgreSQL
2,829,158
227
I have just installed postgresql and I specified password x during installation. When I try to do createdb and specify any password I get the message: createdb: could not connect to database postgres: FATAL: password authentication failed for user Same for createuser. How should I start? Can I add myself as a user...
The other answers were not completely satisfying to me. Here's what worked for postgresql-9.1 on Xubuntu 12.04.1 LTS. Connect to the default database with user postgres: sudo -u postgres psql template1 Set the password for user postgres, then exit psql (Ctrl-D): ALTER USER postgres with encrypted password 'xxxxxxx'...
PostgreSQL
1,471,571
227
Let's say I have a table like this: name | score_a | score_b -----+---------+-------- Joe | 100 | 24 Sam | 96 | 438 Bob | 76 | 101 ... | ... | ... I'd like to select the minimum of score_a and score_b. In other words, something like: SELECT name, MIN(score_a, score_b) FROM table The results...
LEAST(a, b): The GREATEST and LEAST functions select the largest or smallest value from a list of any number of expressions. The expressions must all be convertible to a common data type, which will be the type of the result (see Section 10.5 for details). NULL values in the list are ignored. The result will be NULL o...
PostgreSQL
318,988
227
I have trouble connecting to my own postgres db on a local server. I googled some similar problems and came up with this manual https://help.ubuntu.com/stable/serverguide/postgresql.html so: pg_hba.conf says: # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket con...
The role you have created is not allowed to log in. You have to give the role permission to log in. One way to do this is to log in as the postgres user and update the role: psql -U postgres Once you are logged in, type: ALTER ROLE "asunotest" WITH LOGIN; Here's the documentation http://www.postgresql.org/docs/9.0/...
PostgreSQL
35,254,786
226
I am using Postgres DB for my product. While doing the batch insert using slick 3, I am getting an error message: org.postgresql.util.PSQLException: FATAL: sorry, too many clients already. My batch insert operation will be more than thousands of records. Max connection for my postgres is 100. How to increase the ma...
Just increasing max_connections is bad idea. You need to increase shared_buffers and kernel.shmmax as well. Considerations max_connections determines the maximum number of concurrent connections to the database server. The default is typically 100 connections. Before increasing your connection count you might need to...
PostgreSQL
30,778,015
226
I am trying to query my postgresql db to return results where a date is in certain month and year. In other words I would like all the values for a month-year. The only way i've been able to do it so far is like this: SELECT user_id FROM user_logs WHERE login_date BETWEEN '2014-02-01' AND '2014-02-28' Problem with ...
With dates (and times) many things become simpler if you use >= start AND < end. For example: SELECT user_id FROM user_logs WHERE login_date >= '2014-02-01' AND login_date < '2014-03-01' In this case you still need to calculate the start date of the month you need, but that should be straight forward in a...
PostgreSQL
23,335,970
226
I have two string columns a and b in a table foo. select a, b from foo returns values a and b. However, concatenation of a and b does not work. I tried : select a || b from foo and select a||', '||b from foo Update from comments: both columns are type character(2).
With string types (including character(2)), the displayed concatenation just works because, quoting the manual: [...] the string concatenation operator (||) accepts non-string input, so long as at least one input is of a string type, as shown in Table 9.8. For other cases, insert an explicit coercion to text [...] Bo...
PostgreSQL
19,942,824
226
I have a small table and a certain field contains the type "character varying". I'm trying to change it to "Integer" but it gives an error that casting is not possible. Is there a way around this or should I just create another table and bring the records into it using a query. The field contains only integer values.
There is no implicit (automatic) cast from text or varchar to integer (i.e. you cannot pass a varchar to a function expecting integer or assign a varchar field to an integer one), so you must specify an explicit cast using ALTER TABLE ... ALTER COLUMN ... TYPE ... USING: ALTER TABLE the_table ALTER COLUMN col_name TYPE...
PostgreSQL
13,170,570
226
I'm bulk loading data and can re-calculate all trigger modifications much more cheaply after the fact than on a row-by-row basis. How can I temporarily disable all triggers in PostgreSQL?
Alternatively, if you are wanting to disable all triggers, not just those on the USER table, you can use: SET session_replication_role = replica; This disables triggers for the current session. To re-enable for the same session: SET session_replication_role = DEFAULT; Source: http://koo.fi/blog/2013/01/08/disable-po...
PostgreSQL
3,942,258
225
Postgresql got enum support some time ago. CREATE TYPE myenum AS ENUM ( 'value1', 'value2', ); How do I get all values specified in the enum with a query?
If you want an array: SELECT enum_range(NULL::myenum) If you want a separate record for each item in the enum: SELECT unnest(enum_range(NULL::myenum)) Additional Information This solution works as expected even if your enum is not in the default schema. For example, replace myenum with myschema.myenum. The data ty...
PostgreSQL
1,616,123
224
I am trying to dump a Postgresql database using the pg_dump tool. $ pg_dump books > books.out How ever i am getting this error. pg_dump: server version: 9.2.1; pg_dump version: 9.1.6 pg_dump: aborting because of server version mismatch The --ignore-version option is now deprecated and really would not be a a soluti...
Check the installed version(s) of pg_dump: find / -name pg_dump -type f 2>/dev/null My output was: /usr/pgsql-9.3/bin/pg_dump /usr/bin/pg_dump There are two versions installed. To update pg_dump with the newer version: sudo ln -s /usr/pgsql-9.3/bin/pg_dump /usr/bin/pg_dump --force This will create the symlink to t...
PostgreSQL
12,836,312
223
I would like to manage my Heroku database with pgadmin client. By now, I've been doing this with psql. When I use data from heroku pg:credentials to connect de DB using pgadmin, I obtain: An error has occurred: Error connecting to the server: FATAL: permission denied for database "postgres" DETAIL: User does not hav...
Open the "Properties" of the Heroku server in pgAdminIII and change the "Maintenance DB" value to be the name of the database you want to connect to. The default setup is suitable for DBAs et al who can connect to any database on the server, but apparently that isn't true in your case.
PostgreSQL
11,769,860
222
Some SQL servers have a feature where INSERT is skipped if it would violate a primary/unique key constraint. For instance, MySQL has INSERT IGNORE. What's the best way to emulate INSERT IGNORE and ON DUPLICATE KEY UPDATE with PostgreSQL?
With PostgreSQL 9.5, this is now native functionality (like MySQL has had for several years): INSERT ... ON CONFLICT DO NOTHING/UPDATE ("UPSERT") 9.5 brings support for "UPSERT" operations. INSERT is extended to accept an ON CONFLICT DO UPDATE/IGNORE clause. This clause specifies an alternative action to take in the...
PostgreSQL
1,009,584
221
I'm going to guess that the answer is "no" based on the below error message (and this Google result), but is there anyway to perform a cross-database query using PostgreSQL? databaseA=# select * from databaseB.public.someTableName; ERROR: cross-database references are not implemented: "databaseB.public.someTableName"...
Note: As the original asker implied, if you are setting up two databases on the same machine you probably want to make two schemas instead - in that case you don't need anything special to query across them. postgres_fdw Use postgres_fdw (foreign data wrapper) to connect to tables in any Postgres database - local or re...
PostgreSQL
46,324
220
I have 2 tables as you will see in my PosgreSQL code below. The first table students has 2 columns, one for student_name and the other student_id which is the Primary Key. In my second table called tests, this has 4 columns, one for subject_id, one for the subject_name, then one for a student with the highest score in...
Assuming this table: CREATE TABLE students ( student_id SERIAL PRIMARY KEY, player_name TEXT ); There are four different ways to define a foreign key (when dealing with a single column PK) and they all lead to the same foreign key constraint: Inline without mentioning the target column: CREATE TABLE tests ( ...
PostgreSQL
28,558,920
219
At amazon ec2 RDS Postgresql: => SHOW rds.extensions; rds.extensions -------------------------------------------------------------------------------------------------------------------------...
The extension is available but not installed in this database. CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
PostgreSQL
22,446,478
218
I have a table with over million rows. I need to reset sequence and reassign id column with new values (1, 2, 3, 4... etc...). Is any easy way to do that?
If you don't want to retain the ordering of ids, then you can ALTER SEQUENCE seq RESTART WITH 1; UPDATE t SET idcolumn=nextval('seq'); I doubt there's an easy way to do that in the order of your choice without recreating the whole table.
PostgreSQL
4,678,110
218
How to assign the result of a query to a variable in PL/pgSQL, the procedural language of PostgreSQL? I have a function: CREATE OR REPLACE FUNCTION test(x numeric) RETURNS character varying AS $BODY$ DECLARE name character varying(255); begin name ='SELECT name FROM test_table where id='||x; if(name='test')then ...
I think you're looking for SELECT select_expressions INTO: select test_table.name into name from test_table where id = x; That will pull the name from test_table where id is your function's argument and leave it in the name variable. Don't leave out the table name prefix on test_table.name or you'll get complaints abo...
PostgreSQL
12,328,198
217
How do I change column default value in PostgreSQL? I've tried: ALTER TABLE ONLY users ALTER COLUMN lang DEFAULT 'en_GB'; But it gave me an error: ERROR: syntax error at or near "DEFAULT"
'SET' is forgotten ALTER TABLE ONLY users ALTER COLUMN lang SET DEFAULT 'en_GB';
PostgreSQL
4,745,156
216
The gitpod GitHub page says Gitpod is an open-source Kubernetes application providing prebuilt, collaborative development environments in your browser - powered by VS Code. However, I can not comprehend what it actually does. Can anyone please explain.
Gitpod co-founder here. Gitpod = server-side-dev-envs + dev-env-as-code + prebuilds + IDE + collaboration. From a Git Repository on GitHub, Gitlab or Bitbucket, Gitpod can spin up a server-side-dev-environment for you in seconds. That's a docker container that you can fully customize and that includes your source code...
Gitpod
63,588,658
30
From what I understand: They are both tools to build container images The build itself runs in a container The build can happen on a remote node, for example in a Kubernetes cluster (Kaniko, BuildKit) They both offer advanced features such as layer caching The differences I can gather: Security model (Kaniko) BuildK...
Overlapping features notwithstanding, the primary differences are these: BuildKit Kaniko build with no root or daemon² ✔ ✔ build multi-architecture³ ✔ remote layer caching⁴ ✔ ✔ local layer caching⁵ ✔ ² Both Kaniko and BuildKit can run daemonless and rootless, though Kaniko is, practically speaking ...
kaniko
67,495,607
16
I am interested in setting up a monitoring service that will page me whenever there are too many jobs in the Resque queue (I have about 6 queues, I'll have different numbers for each queue). I also want to setup a very similar monitoring service that will alert me when I exceed a certain amount of failed jobs in my que...
yes it's quite easy, given you're using the Resque gem: require 'resque' Resque.info will return a hash e.g/ => { :pending => 54338, :processed => 12772, :queues => 2, :workers => 0, :working => 0, :failed => 8761, :servers => [ [0] "redis://192.168.1.10:6379/0" ],...
Redis
11,235,318
65
Trying to start Celery first time but issues error as below, i have installed redis and its starting fine , but still somehow django seems to have issues with it , File "<frozen importlib._bootstrap_external>", line 848, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed Fil...
Try to install Redis as in your virtual environment as well: pip install Redis
Redis
70,164,076
65
I want to send a PING to Redis to check if the connection is working, now I could just install redis-cli, but I don't want to and curl is already there. So how can I abuse curl to do that? Basically I need to turn off what's send here: > GET / HTTP/1.1 > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 Open...
When you want to use curl, you need REST over RESP, like webdis, tinywebdis or turbowebdis. See https://github.com/markuman/tinywebdis#turbowebdis-tinywebdis--cherrywebdis $ curl -w '\n' http://127.0.0.1:8888/ping {"ping":"PONG"} Without a REST interface for redis, you can use netcat for example. $ (printf "PING\r\n";...
Redis
33,243,121
65
I'm using Redis 2.8 on Windows which I downloaded from github release. After unzip and I've set maxheap in redis.windows.conf file. After running redis-server redis.windows.conf I get # Creating Server TCP listening socket *:6379:No such file or directory, but redis is not running correctly. I don't know why.
You must've used the .msi installer. It automagically registers a windows service which starts instantly after the installation (at least on my win 10 machine). This service uses the default config and binds to port 6379. When you start redis-server from the command line, if you haven't specified a different port throu...
Redis
31,769,097
65
I am using redis as an in-memory database backend for django cache. In particular, I use django-redis configured as follows: CACHES = { 'default': { 'BACKEND': 'redis_cache.cache.RedisCache', 'KEY_PREFIX': DOMAIN_NAME, 'LOCATION': 'unix:/tmp/redis_6379.sock:1', 'OPTIONS': { ...
I would say there are two possibilities: 1/ The django app may not connect to the Redis instance you think it is connected to, or the redis-cli client you launch does not connect to the same Redis instance. Please note you do not use the same exact connection mechanism in both cases. Django uses a Unix Domain Socket, w...
Redis
17,548,188
65
I've have a Django app that's currently hosted up on Amazon's EC2 service. I have two machines, one with the Django app and the other with my PostgreSQL database. So far it has been rock solid. Many sources claim I should implement Redis into my stack, but what would be the purpose of implementing Redis with Django an...
Redis is a key-value storage system that operates in RAM memory, it's like a "light database" and since it works at RAM memory level it's orders of magnitude faster compared to reading/writing to PostgreSQL or any other traditional Relational Database. Redis is a so-called NoSQL database, like Mongo and many others. It...
Redis
14,989,390
65
I am using Spring Data Redis with Jedis. I am trying to store a hash with key vc:${list_id}. I was able to successfully insert to redis. However, when I inspect the keys using the redis-cli, I don't see the key vc:501381. Instead I see \xac\xed\x00\x05t\x00\tvc:501381. Why is this happening and how do I change this?
Ok, googled around for a while and found help at http://java.dzone.com/articles/spring-data-redis. It happened because of Java serialization. The key serializer for redisTemplate needs to be configured to StringRedisSerializer i.e. like this: <bean id="jedisConnectionFactory" class="org.springframework.data....
Redis
13,215,024
64
I am using sidekiq in my rails application. By Default, Sidekiq can be accessed by anybody by appending "/sidekiq" after the url. I want to password protect / authenticate only the sidekiq part. How can i do that?
Put the following into your sidekiq initializer require 'sidekiq' require 'sidekiq/web' Sidekiq::Web.use(Rack::Auth::Basic) do |user, password| # Protect against timing attacks: # - See https://codahale.com/a-lesson-in-timing-attacks/ # - See https://thisdata.com/blog/timing-attacks-against-string-comparison/ ...
Redis
12,265,421
64
Here is my needs: Enqueue_in(10.hours, ... ) (DJ syntax is perfect.) Multiply workers, concurrently. (Resque or beanstalkd are good for this, but not DJ) Must handle push and pop of 100 jobs a second. (I will need to run a test to make sure, but I think DJ can't handle this many jobs) Resque and beanstalkd don't do ...
For my projects I will feel very comfortbale with collectiveidea/delayed_job in rails2 and 3. I don't know beanstalkd, but i will try it soon :-). I have followed the suggestions in the resque documentation. I will report it. Resque vs DelayedJob How does Resque compare to DelayedJob, and why would you choose one over...
Redis
4,808,351
64
I am aware of redis-cli, and the info and config commands. However, they do not have anything that states the size of the current database. How could I figure this out?
Using the INFO command. full details here: http://redis.io/commands/info sample output: redis-cli redis 127.0.0.1:6379> info redis_version:2.4.11 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:64 multiplexing_api:kqueue gcc_version:4.2.1 process_id:300 uptime_in_seconds:1389779 uptime_in_days:16 lru_clock:1854465...
Redis
14,844,672
63
I've been looking at using Redis Pub/Sub as a replacement to RabbitMQ. From my understanding Redis's pub/sub holds a persistent connection to each of the subscribers, and if the connection is terminated, all future messages will be lost and dropped on the floor. One possible solution is to use a list (and blocking wa...
When a subscriber (consumer) dies, your list will continue to grow until the client returns. Your producer could trim the list (from either side) once it reaches a specific limit, but that is something you would need to handle at the application level. If you include a timestamp within each message, your consumer can...
Redis
6,192,177
63
I have a 20GB+ rdb dump in production. I suspect there's a specific set of keys bloating it. I'd like to have a way to always spot the first 100 biggest objects from static dump analysis or ask it to the server itself, which by the way has ove 7M objects. Dump analysis tools like rdbtools are not helpful in this (I th...
An option was added to redis-cli: redis-cli --bigkeys Sample output based on https://gist.github.com/michael-grunder/9257326 $ ./redis-cli --bigkeys # Press ctrl+c when you have had enough of it... :) # You can use -i 0.1 to sleep 0.1 sec every 100 sampled keys # in order to reduce server load (usually not needed). B...
Redis
13,673,058
62
In my setup, the info command shows me the following: [keys] => 1128 [expires] => 1125 I'd like to find those 3 keys without an expiration date. I've already checked the docs to no avail. Any ideas?
Modified from a site that I can't find now. redis-cli keys "*" | while read LINE ; do TTL=`redis-cli ttl "$LINE"`; if [ $TTL -eq -1 ]; then echo "$LINE"; fi; done; edit: Note, this is a blocking call.
Redis
9,817,951
62
A number of sources, including the official Redis documentation, note that using the KEYS command is a bad idea in production environments due to possible blocking. If the approximate size of the dataset is known, does SCAN have any advantage over KEYS? For example, consider a database with at most 100 keys of the form...
You shouldn't care about current command execution but about the impact to all other commands, since Redis processes commands using a single thread (i.e. while a command is being executed all others need to await until executing one ends). While keys or scan might provide you similar or identical performance executed a...
Redis
32,603,964
61
Is it possible to create namespaces in Redis? From what I found, all the global commands (count, delete all) work on all the objects. Is there a way to create sub-spaces such that these commands will be limited in context? I don't want to set up different Redis servers for this purpose. I assume the answer is "No", and...
A Redis server can handle multiple databases... which are numbered. I think it provides 32 of them by default; you can access them using the -n option to the redis-cli shell scripting command and by similar options to the connection arguments or using the "select()" method on its connection objects. (In this case .sel...
Redis
8,614,858
61
I want to using Redis in laravel 5.2 however, I'm getting error such a Class 'Predis\Client' not found, How I can solve it.
First download the REDIS to your system (if you haven't already installed it). Go to the folder where you have downloaded the redis and run this command: cd your-redis-folder-name make Go to your project directory and install composer: composer require predis/predis Go to your .env file and add Queue driver: QUEUE_D...
Redis
34,865,064
60
I got error NOAUTH Authentication required when I connect to Redis server via command: redis-cli and run ping to check if Redis is working. I found answer for NOAUTH Authentication required error which describes that this error only happens when Redis is set a password, but I checked Redis config file at etc/redis/redi...
We also faced a similar issue. Looks like someone scanned AWS, connected to all public redis servers, and possibly ran "CONFIG SET REQUIREPASS ''", thus locking down the running instance of redis. Once you restart redis, the config is restored to normal. Best thing would be to use AWS security group policy and block po...
Redis
34,115,213
60
Is there any way to remove/delete an entry by key, using Node_redis? I can't see any such option from the docs..
You can del use like this: redis.del('SampleKey');
Redis
15,219,577
60
Simple, probably dumb question: Suppose I have a Java server that stores in memory commonly used keys and values which I can query (let's say in a HashMap) What's the difference between that and using Memcache (or even Redis)? They both store things in memory. Is there a benefit to one or the other? Does Memcache leave...
Advantages of Java memory over memcache: Java memory is faster (no network). Java memory won't require serialization, you have Java objects available to you. Advantages of memcache over Java memory: It can be accessed by more than one application server, so your cache will be shared among all your app servers. It ca...
Redis
5,465,737
60
I have some information stored in my RedisToGo instance in Heroku and I want to wipe it so the Redis store is clean. Any idea how to do this?
You can do this with redis-cli. RedisToGo gives you a url in the form: redis://redistogo:d20739cffb0c0a6fff719acc2728c236@catfish.redistogo.com:9402 So this command will empty your db: redis-cli -h catfish.redistogo.com -p 9402 -a d20739cffb0c0a6fff719acc2728c236 flushall
Redis
9,137,500
59
I'm planning to start using hashes insead of regular keys. But I can't find any information about multi get for hash-keys in Redis wiki. Is this kind of command is supported by Redis? Thank you.
You can query hashes or any keys in pipeline, i.e. in one request to your redis instance. Actual implementation depends on your client, but with redis-py it'd look like this: pipe = conn.pipeline() pipe.hgetall('foo') pipe.hgetall('bar') pipe.hgetall('zar') hash1, hash2, hash3 = pipe.execute() Client will issue one re...
Redis
3,329,408
59
Aerospike is a key-value, in-memory, operational NoSQL database with ACID properties which support complex objects and easy to scale. But I have already used something which does absolutely the same. Redis is also a key-value, in-memory (but persistent to disk) NoSQL database. It also support different complex objects...
If it has to be answered in one word, its "performance". Aerospike's performance is much better than any clustered-nosql solutions out there. Higher performance per-node means smaller cluster which is lower TCO (Total Cost of Ownership) and maintenance. Aerospike does auto-clustering, auto-sharding, auto-rebalancing (w...
Redis
24,482,337
58
In redis there is a SETEX command that allows me to set a key that expires, is there a multi-set version of this command that also has a TTL? both MSET and MSETNX commands do not have such an option.
I was also looking for this kind of operation. I didn't find anything, so I did it with MULTI/EXEC: MULTI expire key1 expire key2 expire key3 EXEC
Redis
16,423,342
58
I have read about Redis and RocksDB, I don't get the advantages of Redis over RocksDB. I know that Redis is all in-memory and RocksDB is in-memory and uses flash storage. If all data fits in-memory, which one should I choose? do they have the same performance? Redis scales linearly with the number of CPU's? I guess tha...
They have nothing in common. You are trying to compare apples and oranges here. Redis is a remote in-memory data store (similar to memcached). It is a server. A single Redis instance is very efficient, but totally non scalable (regarding CPU). A Redis cluster is scalable (regarding CPU). RocksDB is an embedded key/valu...
Redis
31,831,706
57
Sidekiq has been working in development mode just perfectly. Now that I am trying to use it in production, all the jobs are just sitting in enqueue and aren't ever being run. Could anyone point me in the right direction as to how to solve this issue?
Please check if sidekiq process is actually running: ps aux | grep sidekiq If it is not, try to run sidekiq in foreground first and check the output. bundle exec sidekiq -e production
Redis
17,204,826
57
How does Redis handle multiple threads (from different clients) updating the same data structure in Redis ? What is the recommended best practice for such a use case?
if you read the Little redis book at some point this sentence comes. "You might not know it, but Redis is actually single-threaded, which is how every command is guaranteed to be atomic. While one command is executing, no other command will run." Have a look in http://openmymind.net/2012/1/23/The-Little-Redis-Book/ fo...
Redis
17,099,222
57
I'm developing a Python Service(Class) for accessing Redis Server. I want to know how to check if Redis Server is running or not. And also if somehow I'm not able to connect to it. Here is a part of my code import redis rs = redis.Redis("localhost") print rs It prints the following <redis.client.Redis object at 0x120b...
If you want to test redis connection once at startup, use the ping() command. from redis import Redis redis_host = '127.0.0.1' r = Redis(redis_host, socket_connect_timeout=1) # short timeout for the test r.ping() print('connected to redis "{}"'.format(redis_host)) The command ping() checks the connection and if i...
Redis
12,857,604
57
I'm wondering if there's a way to check if a key already exists in a redis list? I can't use a set because I don't want to enforce uniqueness, but I do want to be able to check if the string is actually there. Thanks.
Your options are as follows: Using LREM and replacing it if it was found. Maintaining a separate SET in conjunction with your LIST Looping through the LIST until you find the item or reach the end. Redis lists are implemented as a http://en.wikipedia.org/wiki/Linked_list, hence the limitations. I think your best opti...
Redis
9,312,838
57
Anyone know the difference between redis replication and redis sharding? What are they use for? Redis stores data in memory, how does this affect replication/sharding? Is it possible to use both of them together?
Sharding is almost replication's antithesis, though they are orthogonal concepts and work well together. Sharding, also known as partitioning, is splitting the data up by key; While replication, also known as mirroring, is to copy all data. Sharding is useful to increase performance, reducing the hit and memory load on...
Redis
2,139,443
57
Recently, we had an outage due to Redis being unable to write to a file system (not sure why it's Amazon EFS) anyway I noted that there was no actual HEALTHCHECK set up for the Docker service to make sure it is running correctly, Redis is up so I can't simply use nc -z to check if the port is open. Is there a command I...
Although the ping operation from @nitrin0 answer generally works. It does not handle the case where the write operation will actually fail. So instead I perform a change that will just increment a value to a key I don't plan to use. image: redis:6 healthcheck: test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ] ...
Redis
67,904,609
56
dThe following works as expected. But how do I insert the data into forth database instead of default "0" from command prompt? # echo -n "testing" | /home/shantanu/redis-2.4.2/src/redis-cli -x set my_pass OK # echo -n "testing" | /home/shantanu/redis-2.4.2/src/redis-cli -x select 4; set my_pass (error) ERR wrong numbe...
Just use the -n argument to choose DB number. It available since Redis 2.4.2. echo -n "testing" | redis-cli -n 4 -x set my_pass or redis-cli -n 4 set my_pass testing
Redis
8,253,232
56
We're using AWS, and considering to use DynamoDB or Redis on our new service. Below is our service's character Insert/Delete occur over between hundreds and thousands per minute, and will be larger later. We don't need quick search, only need to find a value with key Data should not be lost. There are another data t...
There are two type of Redis deployment in AWS ElastiCache service: Standalone Multi-AZ cluster With standalone installation it is possible to turn on persistence for a Redis instance, so service can recover data after reboot. But in some cases, like underlying hardware degradation, AWS can migrate Redis to another in...
Redis
56,870,326
55
I am run into trouble .My code below.But I do not know why there is a char 'b' before output string "Hello Python". >>> import redis >>> redisClient = redis.StrictRedis(host='192.168.3.88',port=6379) >>> redisClient.set('test_redis', 'Hello Python') True >>> value = redisClient.get('test_redis') >>> print(value) b'Hell...
It means it's a byte string You can use: redis.StrictRedis(host="localhost", port=6379, charset="utf-8", decode_responses=True) using decode_responses=True to make a unicode string.
Redis
25,745,053
55
I'm getting "OOM command not allowed" when trying to set a key, maxmemory is set to 500M with maxmemory-policy "volatile-lru", I'm setting TTL for each key sent to redis. INFO command returns : used_memory_human:809.22M If maxmemory is set to 500M, how did I reached 809M ? INFO command does not show any Keyspaces , h...
Redis' maxmemory volatile-lru policy can fail to free enough memory if the maxmemory limit is already used by the non-volatile keys.
Redis
18,430,324
55
all: here is my server memory info with 'free -m' total used free shared buffers cached Mem: 64433 49259 15174 0 3 31 -/+ buffers/cache: 49224 15209 Swap: 8197 184 8012 my redis-server has used 46G memor...
More specifically, from the Redis FAQ Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits. In theory the child should use as much memo...
Redis
11,752,544
55
What are the pros and cons of each? Please advice when to use one and not the other.
Data storage Pub/Sub is a Publisher/Subscriber platform, it's not data storage. Published messages evaporate, regardless if there was any subscriber. In Redis Streams, stream is a data type, a data structure on its own right. Messages or entries are stored in memory and stay there until commanded to be deleted. Sync/As...
Redis
59,540,563
54
I'm trying to run sidekiq worker with Rails. When I try to docker-compose up worker I get the following error: worker_1 | Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) worker_1 | /home/app/Nyvur/vendor/bundle/ruby/2.2.0/gems/redis-3.2.2/lib/redis/client.rb:332:in `rescue in establish_connection' wor...
Check if your redis server is running, start redis by using the following command in the terminal: redis-server
Redis
34,729,752
54
What's the easiest way to getting the number (count) of items in Redis set? Preferably without the need to dump whole set and count the lines... So far, I have found only BITCOUNT, which I have not found that useful...
The SCARD command returns the cardinality (i.e. number of items) of a Redis set. http://redis.io/commands/scard There is a similar command (ZCARD) for sorted sets.
Redis
18,056,518
53
I search through redis command list. I couldn't find the command to get all the available channels in redis pub/sub. In meteor server, the equivalent command is LISTCHANNELS, where it lists all known channels, the number of messages stored on each one and the number of current subscribers. I have a cron that needs to p...
PUBSUB CHANNELS does this as of version 2.8.0.
Redis
8,165,188
53
Now I have to use a java client for redis. I have come across Jedis and Redisson. EDIT: Reframing as the question was kind of opinion based. Which is more efficient in terms of speed? Any benchmarks? Which of them is able to provide the following? Distributed locks(and update some keys in a map) Auto key expiry notif...
That question is opinion-based but lets get some objective points into it: TL; DR: The driver choice depends on multiple things: Additional dependencies Programming model Scalability Being opinionated regarding the implementation of high-level features Prospect of your project, the direction in which you want to evolv...
Redis
42,250,951
52
How I can find keys matching a pattern like this: Eg: I have some keys: abc:parent1 abc:parent2 abc:parent1:child1 abc:parent2:child2 How can I find only abc:parent1 abc:parent2
Keys is specifically noted as a command not to be run in production due to the way it works. What you need here is to create an index of your keys. Use a set for storing the key names of the pattern you want. When you add a new we key, add the name of it to the set. For example: Set abc:parent1:child1 breakfast Sadd ab...
Redis
32,474,699
52
I noticed that there are two different projects for using redis for django cache https://github.com/sebleier/django-redis-cache/ https://github.com/niwibe/django-redis Is one better known than the other, more of a standard package? I can't decide which to use.
I am currently using django-redis as cache backend for Redis. I haven't used django-redis-cache so far, but what made me take the decision to use django-redis are the following: Modular client system (pluggable clients). Some of the pluggable clients come out of the box (shard client, herd client, etc.) Master-Slave s...
Redis
21,932,097
52
I want to stop the redis server and it just keeps going and going. I am using redis-2.6.7 Check that it is running: redis-server It says "...bind: Address already in use" so it is already running. I have tried redis-cli redis 127.0.0.1:6379> shutdown It just hangs and nothing happens. I break out and check, yes, it ...
I finally got it down. Get the PID of the process (this worked in Webfaction): ps -u my_account -o pid,rss,command | grep redis Then > kill -9 the_pid I was able to REPRODUCE this issue: Start redis-server Then break it using Pause/Break key Now it hangs and it won't shutdown normally. Also the Python program tryin...
Redis
15,088,053
52
I know there are node.js libraries for Redis; what I'd like to do is run a Redis server (either on localhost or on a server host somewhere) and call it directly via HTTP (i.e. AJAX or HTTP GET as needed) from JavaScript running inside a browser (i.e. a Greasemonkey or Chrome Extension script, or maybe a bookmarklet or ...
You can't connect directly to Redis from JavaScript running in a browser because Redis does not speak HTTP. What you can do is put webdis in front of Redis, it makes it possible work with a Redis instance over a HTTP interface.
Redis
5,759,120
52
What are the implications of disabling gossip, mingle, and heartbeat on my celery workers? In order to reduce the number of messages sent to CloudAMQP to stay within the free plan, I decided to follow these recommendations. I therefore used the options --without-gossip --without-mingle --without-heartbeat. Since then, ...
This is the base documentation which doesn't give us much info heartbeat Is related to communication between the worker and the broker (in your case the broker is CloudAMQP). See explanation With the --without-heartbeat the worker won't send heartbeat events mingle It only asks for "logical clocks" and "revoked tasks" ...
Redis
55,249,197
51
When using the Redis expire commands like SETEX and TTL, there are scenarios in which there is no need for the key to hold a value at all, because the time to live acts as such. However, Redis requires any key to have a value. What would be the most reasonable value to use - if you don't ever want to read it?
Who said that you should actually store anything in redis key? Empty string "" is a perfectly valid value for a redis key, and it's a shortest possible one: > SET foo "" OK > GET foo "" > BITCOUNT foo (integer) 0
Redis
25,557,250
51
I'm using redis-py in my python application to store simple variables or lists of variables in a Redis database, so I thought it would be better to create a connection to the redis server every time I need to save or retrieve a variable as this is not done very often and I don't want to have a permanent connection that...
Python uses a reference counter mechanism to deal with objects, so at the end of the blocks, the my_server object will be automatically destroyed and the connection closed. You do not need to close it explicitly. Now this is not how you are supposed to manage Redis connections. Connecting/disconnecting for each operati...
Redis
12,967,107
51