且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PostgreSQL类似的SQL Server索引(包括列)

更新时间:2023-02-05 08:37:01

CREATE INDEX myindex ON mytablename (co1l, col2, col3, col4)

PostgreSQL 不支持聚集索引或覆盖索引。

PostgreSQL does not support clustered or covering indexes.

更新:

对于此查询,您确实需要创建建议的索引:

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.

您可以在表的单个 INT 字段中保留年,月和日。

You can keep year, month and day in a single INT field in your table. This will save you a join.

可能会保留 DataMessage 如果 GpsDetails 很少链接到 DataMessage (即, gps_details_id 通常设置为 NULL ),或者GPS细节记录可以在多条数据消息之间共享。

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.

不是,***将GPS详细信息移到数据消息表中。

It it's not, it will be better to move the GPS details into the data messages table.