PostgreSQL analogue of SQL Server index (including columns)

Trying to recreate my SQL Server database on PostgreSQL. Everything is fine, but I cannot find how to recreate this index:

USE [mytablename]  
GO  
CREATE NONCLUSTERED INDEX [myindex]  
ON [dbo].[mytablename] ([col1],[col2])  
INCLUDE ([col3],[col4])  
GO  

We will be very grateful for your help.

Alexei

Update:

http://img38.imageshack.us/img38/1071/89013974.png there is a structure db star + eav
there is only one request

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 [scoutserver_data].[dbo].[DataMessage]  this_   
WHERE this_.time_id = 65536 and this_.device_id = 32768  

Perhaps this is not optimal atm. And I am also working on this. Maybe something like this

SELECT * FROM [scoutserver_data].[dbo].[TimeDimension]   
  INNER JOIN ([scoutserver_data].[dbo].[DeviceDimension]   
  INNER JOIN  [scoutserver_data].[dbo].[DataMessage]   
ON [DeviceDimension].[device_id] =[DataMessage].[device_id])  
ON [TimeDimension].[time_id] = [DataMessage].[time_id]  
WHERE DeviceDimension.serial_id='2' AND TimeDimension.Day=15 AND TimeDimension.Year=2009

Any hints welcome =)

+8
source share
3 answers
CREATE INDEX myindex ON mytablename (co1l, col2, col3, col4)

PostgreSQL Does not support clustered or spanning indexes.

Update:

:

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)

, .

, INT . .

DataMessage GpsDetails, GpsDetails DataMessage ( , gps_details_id NULL), GPS .

, GPS .

+10

PostgreSQL 11 . PostgreSQL 11 - INCLUDE B-:

INCLUDE . , . INCLUDE , . , . INCLUDE, .

B- INCLUDE.

CREATE INDEX myindex ON mytablename (col1,col2) INCLUDE (col3,col4); 

:

:

[ (_ [,...])]

INCLUDE , . , - , . , . , , .

, INCLUDE, ; , , .

, .

B- . B- , INCLUDE, , , , .

+9

​​ - PostgreSQL. , , , , . .

. , postgres ( ) , .

+2

Source: https://habr.com/ru/post/1721496/


All Articles