This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
number_of_runs = # how many times to repeat the check | |
number_of_threads = # how many concurrent write request | |
write_url = # url to use for the write requests | |
write_params = # params to send in each write request | |
read_url = # url used to check the state of the system after the concurrent write requests | |
number_of_runs.times do |i| | |
puts “run ##{i+1}” | |
concurrent_post(number_of_threads, write_url, write_params) | |
state = get(read_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT id, genre, title from films; | |
id | genre | title | |
----+----------+------------------- | |
1 | thriller | Blade Runner 2049 | |
2 | thriller | Inception | |
3 | scifi | Arrival |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT id, film_id, content FROM reviews; | |
id | film_id | content | |
----+---------+----------------------------------------------------------- | |
1 | 1 | Visually stunning and thought provoking, but not flawless | |
2 | 1 | One of the best sequels of all time | |
3 | 1 | Strangely boring, lacking tension and intelligence | |
4 | 2 | Amazing Directing, Captivating Plot, Overall Great |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT genre, count(*) FROM films GROUP BY genre; | |
genre | count | |
----------+------- | |
thriller | 2 | |
scifi | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT title, genre, count(*) FROM films GROUP BY genre; | |
ERROR: column "films.title" must appear in the GROUP BY clause or be used in an aggregate function | |
LINE 1: SELECT title, genre, count(*) FROM films GROUP BY genre; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT title, genre, count(*) FROM films GROUP BY title, genre; | |
title | genre | count | |
-------------------+----------+------- | |
Blade Runner 2049 | thriller | 1 | |
Inception | thriller | 1 | |
Arrival | scifi | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT string_agg(title, ', ') as titles, genre, count(*) FROM films GROUP BY genre; | |
titles | genre | count | |
------------------------------+----------+------- | |
Blade Runner 2049, Inception | thriller | 2 | |
Arrival | scifi | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT id, title, genre FROM films GROUP BY id; | |
id | title | genre | |
----+-------------------+---------- | |
3 | Arrival | scifi | |
1 | Blade Runner 2049 | thriller | |
2 | Inception | thriller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT films.id, films.title, films.genre, count(*) as number_of_reviews FROM films LEFT JOIN reviews ON films.id = reviews.film_id GROUP BY films.id; | |
id | title | genre | number_of_reviews | |
----+-------------------+----------+------------------- | |
3 | Arrival | scifi | 1 | |
1 | Blade Runner 2049 | thriller | 3 | |
2 | Inception | thriller | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> SELECT films.id, films.title, films.genre, string_agg(reviews.content, E'\n') FROM films LEFT JOIN reviews ON films.id = reviews.film_id GROUP BY films.id; | |
id | title | genre | string_agg | |
----+-------------------+----------+----------------------------------------------------------- | |
3 | Arrival | scifi | | |
1 | Blade Runner 2049 | thriller | Visually stunning and thought provoking, but not flawless+ | |
| | | One of the best sequels of all time + | |
| | | Strangely boring, lacking tension and intelligence | |
2 | Inception | thriller | Amazing Directing, Captivating Plot, Overall Great |
OlderNewer