Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6163925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:54:25+00:00 2026-05-23T21:54:25+00:00

I’m definitely not a DBA and unfortunately we don’t have a DBA to consult

  • 0

I’m definitely not a DBA and unfortunately we don’t have a DBA to consult within at our company. I was wondering if someone could give me a recommendation on how to improve this query, either by changing the query itself or adding indexes to the database.

Looking at the execution plan of the query it seems like the outer joins are killing the query. This query only returns 350k results, but it takes almost 30 seconds to complete. I don’t know much about DB’s, but I don’t think this is good? Perhaps I’m wrong?

Any suggestions would be greatly appreciated. Thanks in advance.

As a side note this is obviously being create by an ORM and not me directly. We are using Linq-to-SQL.

SELECT 
    [t12].[value] AS [DiscoveryEnabled], 
    [t12].[value2] AS [isConnected], 
    [t12].[Interface], 
    [t12].[Description] AS [InterfaceDescription], 
    [t12].[value3] AS [Duplex], 
    [t12].[value4] AS [IsEnabled], 
    [t12].[value5] AS [Host], 
    [t12].[value6] AS [HostIP], 
    [t12].[value7] AS [MAC], 
    [t12].[value8] AS [MACadded], 
    [t12].[value9] AS [PortFast], 
    [t12].[value10] AS [PortSecurity], 
    [t12].[value11] AS [ShortHost], 
    [t12].[value12] AS [SNMPlink], 
    [t12].[value13] AS [Speed], 
    [t12].[value14] AS [InterfaceStatus], 
    [t12].[InterfaceType], 
    [t12].[value15] AS [IsUserPort], 
    [t12].[value16] AS [VLAN], 
    [t12].[value17] AS [Code], 
    [t12].[Description2] AS [Description], 
    [t12].[Host] AS [DeviceName], 
    [t12].[NET_OUID], 
    [t12].[DisplayName] AS [Net_OU], 
    [t12].[Enclave]
FROM (
    SELECT 
        [t1].[DiscoveryEnabled] AS [value], 
        [t1].[IsConnected] AS [value2], 
        [t0].[Interface], 
        [t0].[Description], 
        [t2].[Duplex] AS [value3], 
        [t0].[IsEnabled] AS [value4], 
        [t3].[Host] AS [value5], 
        [t6].[Address] AS [value6], 
        [t3].[MAC] AS [value7], 
        [t3].[MACadded] AS [value8], 
        [t2].[PortFast] AS [value9], 
        [t2].[PortSecurity] AS [value10], 
        [t4].[Host] AS [value11], 
        [t0].[SNMPlink] AS [value12], 
        [t2].[Speed] AS [value13], 
        [t2].[InterfaceStatus] AS [value14], 
        [t8].[InterfaceType], 
        [t0].[IsUserPort] AS [value15], 
        [t2].[VLAN] AS [value16], 
        [t9].[Code] AS [value17], 
        [t9].[Description] AS [Description2], 
        [t7].[Host], [t7].[NET_OUID], 
        [t10].[DisplayName], 
        [t11].[Enclave], 
        [t7].[Decommissioned]
    FROM [dbo].[IDB_Interface] AS [t0]
        LEFT OUTER JOIN [dbo].[IDB_InterfaceLayer2] AS [t1] ON [t0].[IDB_Interface_ID] = [t1].[IDB_Interface_ID]
        LEFT OUTER JOIN [dbo].[IDB_LANinterface] AS [t2] ON [t1].[IDB_InterfaceLayer2_ID] = [t2].[IDB_InterfaceLayer2_ID]
        LEFT OUTER JOIN [dbo].[IDB_Host] AS [t3] ON [t2].[IDB_LANinterface_ID] = [t3].[IDB_LANinterface_ID]
        LEFT OUTER JOIN [dbo].[IDB_Infrastructure] AS [t4] ON [t0].[IDB_Interface_ID] = [t4].[IDB_Interface_ID]
        LEFT OUTER JOIN [dbo].[IDB_AddressMapIPv4] AS [t5] ON [t3].[IDB_AddressMapIPv4_ID] = ([t5].[IDB_AddressMapIPv4_ID])
        LEFT OUTER JOIN [dbo].[IDB_AddressIPv4] AS [t6] ON [t5].[IDB_AddressIPv4_ID] = [t6].[IDB_AddressIPv4_ID]
        INNER JOIN [dbo].[ART_Asset] AS [t7] ON [t7].[ART_Asset_ID] = [t0].[ART_Asset_ID]
        LEFT OUTER JOIN [dbo].[NSD_InterfaceType] AS [t8] ON [t8].[NSD_InterfaceTypeID] = [t0].[NSD_InterfaceTypeID]
        INNER JOIN [dbo].[NSD_InterfaceCode] AS [t9] ON [t9].[NSD_InterfaceCodeID] = [t0].[NSD_InterfaceCodeID]
        INNER JOIN [dbo].[NET_OU] AS [t10] ON [t10].[NET_OUID] = [t7].[NET_OUID]
        INNER JOIN [dbo].[NET_Enclave] AS [t11] ON [t11].[NET_EnclaveID] = [t10].[NET_EnclaveID]
    ) AS [t12]
WHERE ([t12].[Enclave] = 'USMC') AND (NOT ([t12].[Decommissioned] = 1))

LINQ-TO-SQL Query:

return from t in db.IDB_Interfaces
             join v in db.IDB_InterfaceLayer3s on t.IDB_Interface_ID equals v.IDB_Interface_ID
             join u in db.ART_Assets on t.ART_Asset_ID equals u.ART_Asset_ID
             join c in db.NET_OUs on u.NET_OUID equals c.NET_OUID
             join w in
               (from d in db.IDB_InterfaceIPv4s
                select new { d.IDB_InterfaceIPv4_ID, d.IDB_InterfaceLayer3_ID, d.IDB_AddressMapIPv4_ID, d.IDB_AddressMapIPv4.IDB_AddressIPv4.Address })
             on v.IDB_InterfaceLayer3_ID equals w.IDB_InterfaceLayer3_ID
             join h in db.NET_Enclaves on c.NET_EnclaveID equals h.NET_EnclaveID into enclaveLeftJoin
             from i in enclaveLeftJoin.DefaultIfEmpty()
             join m in
               (from z in db.IDB_StandbyIPv4s
                select new
                {
                  z.IDB_InterfaceIPv4_ID,
                  z.IDB_AddressMapIPv4_ID,
                  z.IDB_AddressMapIPv4.IDB_AddressIPv4.Address,
                  z.Preempt,
                  z.Priority
                })
             on w.IDB_InterfaceIPv4_ID equals m.IDB_InterfaceIPv4_ID into standbyLeftJoin
             from k in standbyLeftJoin.DefaultIfEmpty()
             where t.ART_Asset.Decommissioned == false
             select new NetIDBGridDataResults
             {
               DeviceName = u.Host,
               Host = u.Host,
               Interface = t.Interface,
               IPAddress = w.Address,
               ACLIn = v.InboundACL,
               ACLOut = v.OutboundACL,
               VirtualAddress = k.Address,
               VirtualPriority = k.Priority,
               VirtualPreempt = k.Preempt,
               InterfaceDescription = t.Description,
               Enclave = i.Enclave
             };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:54:26+00:00Added an answer on May 23, 2026 at 9:54 pm

    As a rule (and this is very general), you want an index on:

    • JOIN fields (both sides)
    • Common WHERE filter fields
    • Possibly fields you aggregate

    For this query, start with checking your JOIN criteria. Any one of those missing will force a table scan which is a big hit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.