/rails-lab-with-postgres

Rails Lab with Postgres

Primary LanguageRuby

README

The purpose of this project is to study postgresql with Rails.

Docker compose

For now the docker-compose.yml only have PostgreSQL and pgAdmin. You can start this dependencies with:

docker-compose up

pgAdmin

URL: http://localhost:80/

email: admin@root.com
password: SuperSecret

How to connect to PostgresSQL using pgAdmin?

Host name/address: postgresdb
username: index_demo
password: index_demo

How to create valid data?

Go to the console with rails c and populate the database using factory bot: FactoryBot.create_list(:user, 500000). The number of users is up to you.

Features

Index

For now we can run rails db:rollback, with the objective to remove the indexs, and rails db:migrate to add the indexs. Run the SQLs between this commands and see for yourself the results.

Example of Sql to test index_users_on_lower_first_name_varchar_pattern_ops

SELECT *
FROM users
WHERE lower(first_name) LIKE 'theodore%';

Example of Sql to test index_users_on_regexp_replace_phone_0_9

SELECT *
FROM users
WHERE regexp_replace(phone, '[^0-9]+', '') LIKE '5639%';