B
B
Bogdan2017-07-31 16:50:21
Ruby on Rails
Bogdan, 2017-07-31 16:50:21

RAILS result from multiple requests?

Hello. Tell me please. The database used is PostgreSQL. For optimization purposes, I decided to combine several queries into one, how to get results from all queries, otherwise it returns only from the last one. Thank you.

sql = "SELECT number FROM institution_orders WHERE institution_id = 980190990 ORDER BY id DESC LIMIT 1;" +      
     "select prefix from institutions where id = 980190990 limit 1"

record = JSON.parse( ActiveRecord::Base.connection.execute( sql ).to_json, symbolize_name: true ) 
# [{"prefix"=>"KL"}]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Andreev, 2017-07-31
@b0nn1e

I think you are doing something crazy.
The first stage of optimization is measurements .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question