Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [rails]

Rails is a cross-platform model-view-controller-centric application framework for Ruby. Use this tag for database-related Rails questions.

0
votes
0answers
14 views

Postgres INSERT slows down over time until server is restarted

I have a Rails app backed by an Azure-managed Postgres database and I use NewRelic for monitoring. What I've noticed is that the INSERT performance degrades almost linearly over time - what started ...
-3
votes
1answer
138 views

Postgres is Throwing a False Foreign Key Constraint Violation? [closed]

I am trying to delete a LocalTax record from Postgres. Currently, I don't think there are any Employee records that reference the LocalTax in question (8). => SELECT COUNT(*) FROM employees WHERE ...
1
vote
2answers
34 views

MySQL failover: how application can be switched to a new master in master-slave configuration?

In my case I have two MySQL servers. One is master and second one is slave. When slave is not available, my application can read and write from/to master. When master is not available, assume there ...
0
votes
1answer
70 views

PostgreSQL query suddenly very slow after new column addition

I have a query that's performing terribly after adding a new column. Here's the slow version: SELECT COUNT(*) FROM activities INNER JOIN "users" ON "users"."id" = "activities"."user_id" AND "users"."...
0
votes
1answer
35 views

Postgresql Query getting slow execution time

I did the explain analyze for this query, it was giving 30ms, but if the data is more I will get an execution expired; Using PostgreSQL 10 For normal execution: https://explain.depesz.com/s/gSPP For ...
1
vote
1answer
49 views

SQL row data mismatch for different users

I am using MySQL (version 5.5.43) as my database. I have a RoR micro-service that does an update column to a model Active Record class: model.update_column(status: 0) The next line is an api call ...
2
votes
2answers
1k views

Set search path for Postgres in a Rails app

I have a project in heroku. I have the URI that enables me to connect with the database in my external rails app. How do I change or set the search path in ruby code?
0
votes
1answer
26 views

Flashcards and templates

I'm having trouble with an appropriate DB design for flashcards that display their data with one of numerous templates. A user has many flashcards. They pick the card template during creation. There ...
1
vote
1answer
53 views

How can I join this two queries,in one? [closed]

I have this 2 queries, and I would like to join them First query SELECT proveedors.nombre as proveedor, COUNT(productos.id) as distintos FROM proveedors INNER JOIN productos ON proveedors.id = ...
1
vote
1answer
585 views

How can I use value of the id column as default value of another non-nullable column when using postgresql-rails?

Here's one example where such a requirement comes up: Suppose we have a table 'sample' in our database which has a column 'col1' and an auto-incremental 'id' column. We want the default value of '...
0
votes
1answer
242 views

Understanding Simple MongoDB Replication Works

I've been using MongoDB (3.2.9) replication for years and barely know the detail how it works. My Stack is Rails 4.2.5 with Mongoid 5.1.3. I've 3 database servers, let's call them A (Primary), B (...
1
vote
3answers
580 views

How to store short stories for access to individual sentences?

I am building a database for the first time ever (using PostgreSQL), and am very conflicted over the most efficient/logical way of storing a body of text (aka, a story). The conflict stems from the ...
0
votes
1answer
48 views

re-write active record query to PostgreSQL

I want to rewrite the active record query to Actual PostgreSQL query Camera.joins("left JOIN users on cameras.owner_id = users.id") .joins("left JOIN vendor_models vm on cameras....
4
votes
1answer
535 views

What can I do to monitor “out of shared memory” issues?

I'm new to database administration and I would really like some advice on what tools I could use or what I could do to monitor "out of shared memory" issues. I've been seeing these "out of shared ...
3
votes
2answers
897 views

Efficient schema to handle time interval queries on a huge table?

We have huge table (+10 millions rows) where we aggregate the values by a using a time interval search on a Datetime column. And right now, to build single page on our app, we are querying this table ...
0
votes
2answers
3k views

MySQL database has way too many connections

I have a MySQL version 5.7.12 database that has 4 applications running against them. Two of these applications are single webservers running Rails apps. The other two applications are also Rails ...
1
vote
1answer
1k views

Cannot start both neo4j development and neo4j test servers

I have a Rails application backed by a Neo4j database. I've installed both a development server and a test server, as explained here and here. Each server works fine when started up alone, but if I ...
2
votes
2answers
4k views

MySQL create index with LOCK=NONE still locks a table

I have the following MySQL RoR Migrations: class ReindexRpushNotification < ActiveRecord::Migration def up execute("DROP INDEX `index_rpush_notifications_multi` ON rpush_notifications;") ...
1
vote
1answer
2k views

In Rails: How is existing data affected by data type change?

I'm working on a Rails app and would like to change the datatype for an existing column. It's currently a DateTime type, and I want to change it to a Date type. I found a way to do this here, but in ...
1
vote
1answer
1k views

Postgres: querying jsonb array with an array

My products table has a jsonb column called 'specs'. This specs hash will often have an array field, let's call it 'spec_options'. When querying this table, I need to find any product that has ...
0
votes
1answer
62 views

Source of error on psql data load

Upon importing a file derived from rails establishment, psql is hitting the error of foreign key constraints: ERROR: insert or update on table "documents" violates foreign key constraint "...
0
votes
2answers
55 views

Database Design - I have a question regarding joining tables

Forgive me for my dumb question but I am new to Ruby on Rails and data design. We all have to start somewhere right? Well my question is that I want to build a database for a Truck driving company. It ...
0
votes
3answers
111 views

Constructing 3-step sql query

I have: a table of Characters with a character_id column; a join table of Chats with character_id and conversation_id columns; and a table of Conversations with a conversation_id column. I am ...
2
votes
2answers
3k views

MySQL: How to decrease sleep process's time out?

When I run 'show processlist;', then I get so many sleep processes. I set wait_timeout and interactive_timeout to 60 in my.cnf. But, sleep process is not died when time 60 on processlist. I found ...
0
votes
0answers
144 views

Proper handling of errors on pg_restore

Following the execution of pg_dump -Fc the follow-up pg_restore is generating errors. Under pg_restore -c -v -1 -d the following error is generated Error while PROCESSING TOC: The motive is: ...
0
votes
0answers
74 views

accessing postgis extension capabilities

The context is pertinent as it demonstrates behaviour different than other (more manual) successful attempts. Deploying a rails application with postgres and postgis extension to AWS EC2 instance, ...
3
votes
1answer
222 views

Inventory management in Rails

I'm creating a inventory management app in rails. I have an User Table and a Recipe table, there is also some tables with types of material (pens, sharpies, paper, and so on). Because there is a lot ...
0
votes
0answers
129 views

Adding postgis geometry with rake task

I have a postgres table test with a geometry column: Column | Type | Modifiers --------------...
2
votes
1answer
729 views

PostgreSQL: restore a record from a backup

We have a Rails app backed by a PostgreSQL DB and hosted on Heroku. We recently had a bug that deleted some (very few before we caught it) records. Excuse my ignorance but is there a straightforward ...
0
votes
1answer
68 views

What postgres sync solution should I use to duplicate production, but read it from another application?

I'm a little out of my league with my current problem, but I'm looking for a solution where the following conditions are met: My production database reads and writes as it currently does My ...
2
votes
1answer
11k views

How to convert time without time zone to timestamp without time zone in PostgreSQL?

I received this error when trying to alter a column of type time to type timestamp: PG::CannotCoerce: ERROR: cannot cast type time without time zone to timestamp without time zone It's not ...
2
votes
1answer
257 views

Copying database to different hard disk

Total noob at database administration here, excuse my ignorance. I have a server running a Rails application that's using PostgreSQL. The database is saved on drive /z/, which seems to have filled up....
6
votes
1answer
3k views

PostgreSQL 9.3 Amazon RDS gives error while using UUID-OSSP extension for generating uuid

I have created DB instance on RDS and used below function. It gave error while with the same PostgreSQL version on a local development machine it works fine. create or replace function uuid() returns ...
0
votes
0answers
103 views

Multi-Tiered Database Design Issue

I am trying to build the multi-level model as demonstrated. When a user creates a campaign they will select some categories and some metros from tables Category and Metro. Those selections will then ...
1
vote
0answers
587 views

On Heroku in production, how can I copy database A to database B on command?

From my local terminal, I can use the following commands to do what I need to do: heroku pgbackups:capture --expire heroku pgbackups:restore charcoal --confirm max-kiosk However, I want to do this ...
0
votes
1answer
289 views

Duplicate Relationships in Rails/MySQL Healthcare Application

Overview of the Application I am building a Ruby on Rails application to organize medications, using MySQL. The goal of this application is to provide dosage specific treatment recommendations, and ...
0
votes
1answer
1k views

While importing 150 GB file on Amazon RDS, why connection is failing?

I am having Postgres database dump file of 150 GB on Amazon EC2 instance. While dumping the data on RDS from EC2 server I am getting error. The output of the command is as given below. It's giving ...
0
votes
0answers
1k views

Can’t connect to local PostgresSQL server

I have the Postres app installed an running on my Mac. And it has worked beautifully. I don’t know what changed, but now I cannot connect to it from Rails, PG Commander, PG Admin or the command psql -...
1
vote
1answer
96 views

Why add indexes to these columns in the Database?

I am trying to get my head around this code. It's from the Rails Tutorial Book and is part of the process of making a twitter like application. class CreateRelationships < ActiveRecord::...