Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. face time out when run query with nested select

face time out when run query with nested select

Scheduled Pinned Locked Moved Database
databasehelp
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mhd sbt
    wrote on last edited by
    #1

    hi to all when i run this query i faced with timeout

    DELETE FROM bml.LoanInstallment WHERE ID IN (select * from wfInstanceNodes where ID=@nodeID)

    this occurred when nested select return null and i think it is because of that i have no index on id; and i set index to id but still this query faced with time out note that bml.LoanInstallment has 11000000 record and this query run without problem for a table with a few records. thanks for any help

    B L P 3 Replies Last reply
    0
    • M mhd sbt

      hi to all when i run this query i faced with timeout

      DELETE FROM bml.LoanInstallment WHERE ID IN (select * from wfInstanceNodes where ID=@nodeID)

      this occurred when nested select return null and i think it is because of that i have no index on id; and i set index to id but still this query faced with time out note that bml.LoanInstallment has 11000000 record and this query run without problem for a table with a few records. thanks for any help

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      Do you run into a timeout when you do a SELECT instead of a DELETE? E.g. SELECT COUNT(ID) FROM bml... etc.? And how many entries are to be deleted? Are there indices for the ID columns in both tables? Are there any constraints, e.g. an OnDeleteCascade?

      M 1 Reply Last reply
      0
      • M mhd sbt

        hi to all when i run this query i faced with timeout

        DELETE FROM bml.LoanInstallment WHERE ID IN (select * from wfInstanceNodes where ID=@nodeID)

        this occurred when nested select return null and i think it is because of that i have no index on id; and i set index to id but still this query faced with time out note that bml.LoanInstallment has 11000000 record and this query run without problem for a table with a few records. thanks for any help

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Your subquery should not select "all" columns, only the ID-column.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        M 1 Reply Last reply
        0
        • L Lost User

          Your subquery should not select "all" columns, only the ID-column.

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

          M Offline
          M Offline
          mhd sbt
          wrote on last edited by
          #4

          ok i use select id instead of select * but im still face with timeout i think that this is because of that my nested select return an empty column what you thinks ? how can i handle this problem? thanks for answer

          L 1 Reply Last reply
          0
          • B Bernhard Hiller

            Do you run into a timeout when you do a SELECT instead of a DELETE? E.g. SELECT COUNT(ID) FROM bml... etc.? And how many entries are to be deleted? Are there indices for the ID columns in both tables? Are there any constraints, e.g. an OnDeleteCascade?

            M Offline
            M Offline
            mhd sbt
            wrote on last edited by
            #5

            id is uniqueness and and one entries finally will be deleted. and i don't have any constraint on bml table thanks in advanced

            1 Reply Last reply
            0
            • M mhd sbt

              hi to all when i run this query i faced with timeout

              DELETE FROM bml.LoanInstallment WHERE ID IN (select * from wfInstanceNodes where ID=@nodeID)

              this occurred when nested select return null and i think it is because of that i have no index on id; and i set index to id but still this query faced with time out note that bml.LoanInstallment has 11000000 record and this query run without problem for a table with a few records. thanks for any help

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Personally, I don't like sub-selects (they seem so 90s), I'd rather JOIN them. (Provided your system allows it)

              -- Transact-SQL extension
              USE AdventureWorks2012;
              GO
              DELETE FROM Sales.SalesPersonQuotaHistory
              FROM Sales.SalesPersonQuotaHistory AS spqh
              INNER JOIN Sales.SalesPerson AS sp
              ON spqh.BusinessEntityID = sp.BusinessEntityID
              WHERE sp.SalesYTD > 2500000.00;

              1 Reply Last reply
              0
              • M mhd sbt

                ok i use select id instead of select * but im still face with timeout i think that this is because of that my nested select return an empty column what you thinks ? how can i handle this problem? thanks for answer

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                mhd.sbt wrote:

                i use select id instead of select * but im still face with timeout

                A command-timeout or a connection-timeout? How long does the query take when run on the server directly? Can you post the schema of the tables here? It would be weird if you'd select the same key that you're filtering on.

                mhd.sbt wrote:

                what you thinks ?

                I'm pretty sure that you can select "where in null" without hitting performance-problems of said magnitude.

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                M 1 Reply Last reply
                0
                • L Lost User

                  mhd.sbt wrote:

                  i use select id instead of select * but im still face with timeout

                  A command-timeout or a connection-timeout? How long does the query take when run on the server directly? Can you post the schema of the tables here? It would be weird if you'd select the same key that you're filtering on.

                  mhd.sbt wrote:

                  what you thinks ?

                  I'm pretty sure that you can select "where in null" without hitting performance-problems of said magnitude.

                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                  M Offline
                  M Offline
                  mhd sbt
                  wrote on last edited by
                  #8

                  thanks for your time to answer this problem. i found problem that i posted it in a solution

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups