**Question:** Is there a better indexing strategy or query SELECT that I can use for looking up one large data set against another large data set? Or, should I look at placing the lookup dimension table in memory (all 125 GB of it)? **Server Configuration:** - The server is a virtual server running on top of VMWare, so additional hardware can be added in the background without having to reinstall the operating system - Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64) Aug 22 2017 17:04:49 Copyright (C) 2017 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) (Hypervisor) - **Note:** I was previously on 2014 Enterprise - I have inquired why I was placed on Standard. - There is only one instance that is running 2 databases: mine and the DBAs - 2 File groups, with 1 file each: PRIMARY (system tables : not-default) and SECONDARY (non-system tables : default). The SECONDARY was meant to be scalable to hold more files once more CPUs were added. When the file group was initially created the server only had 2 CPUs - 8 GB memory - 500 GB disk storage (ISCSI SAN) - 4 CPUs (Intel I assume) I have two data sets: IIS Exchange Server IP log records and IP GeoLocation data provided by a 3rd party vendor; where the Geolocation covers a range of IP addresses. I need to lookup the IP address from the log file and get its GeoLocation. Both data sets accommodate for IPv4 and IPv6 and the IP address is received in string format. When I load the data, I convert the IP address into a hexadecimal value [VARBINARY(16)] so that I can lookup an IP addresses GeoLocation. The problem here is that I am loading a large amount of records. Currently, the vendor provides close to 200 million IP address Geolocations (i.e., dimension lookup table). I knew from the inception that performance optimization will be required at all stages (i.e., hardware configuration, table partitioning, and indexing strategy). I have loaded one week's worth of sample log data and that is approximately 150 million records. **Note:** The log files are parsed where approximately 90% of records are ignored - we are only loading 10% of the records, so there is no performance boost that can be made here I have created the following indexes on the ExchangeLogs table: 1. A clustered index on an integer IDENTITY column called RowId 2. A non-clustered index on the ProtocolId (i.e., IPv4 or IPv6 represented as integers), IpHex; where the RowId is included I have created the following indexes on the IPGeoLocation table: 1. A clustered index on an integer IDENTITY column called RowId 2. A non-clustered index on the ProtocolId (i.e., IPv4 or IPv6 represented as integers), StartIpHex, and EndIpHex; where the RowId is included When searching for the IP Geolocation, I join the two datasets as follows: SELECT RowId FROM ExchangeLogs E INNER JOIN IpGeoLocation I ON E.ProtocolId = I.ProtocolId AND E.IpAddress **BETWEEN** I.StartIpHex AND I.EndIpHex **Note 2:** The ProtocolId must be included, otherwise there are two results for each IP lookup: one for IPv4 and one for IPv6. This works in finding the IP Address and the execution plan shows the following: [![Execution Plan][1]][1] This seems like a very efficient execution plan considering 95% of the cost is on an index **seek** and another 2% on an index **scan** - 97% is attributed to index work. The log files contain both internal and external IP Address on each row. For the sample data loaded: 1. The Internal IP list contains 3 DISTINCT IP addresses. 2. The external IP list contains approximately 60,000 DISTINCT IP Address. **Results:** 1. A SELECT on the internal IP list takes about 9 minutes to complete. 2. A SELECT on the external IP list was **stopped** after allowing it to run for 16.25 hours (overnight). I have not partitioned either the log table or the IP GeoLocation table. This might provide a performance boost by streaming data through two separate LUNs, but I am still trying to get a hardware configuration specification from our IT Ops group (they just provisioned new servers, so I don't have that info yet). [1]: https://i.sstatic.net/MxDox.png