для данного файлового объекта (здесь, в rails)
file = File.open(File.join(Rails.root, 'lib', 'file.json'))
file.readlines.count
возвращает количество строк
IO # readlines выполняет метод разделения строк (в данном случае IOStrings), используя переводы в качестве разделителя
CREATE INDEX myindex ON mytablename (co1l, col2, col3, col4)
PostgreSQL
does not support clustered or covering indexes.
Update:
For this query, you'll need to create the suggested index indeed:
SELECT this_.id as id0_0_,
this_.device_id as device2_0_0_,
this_.time_id as time3_0_0_,
this_.gps_detail_id as gps4_0_0_
FROM DataMessage this_
WHERE this_.time_id = 65536
AND this_.device_id = 32768
CREATE INDEX ix_datamessage_time_device_id_detail ON datamessage (time_id, device_id, id, gps_detail_id)
However, your tables seem to be over-normalized to me.
You can keep year, month and day in a single INT
field in your table. This will save you a join.
There might be the point of keeping DataMessage
and GpsDetails
in separate tables if either GpsDetails
are rarely linked to the DataMessage
(this is, gps_details_id
is often set to NULL
), or a GPS details record can be shared between multiple data messages.
It it's not, it will be better to move the GPS details into the data messages table.