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. a query by less performnace

a query by less performnace

Scheduled Pinned Locked Moved Database
databasecsssql-serversysadminperformance
7 Posts 3 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 im face with low performance by below query in sql server 2008 any one can help me. my query is goon work when top has larg number but when top has less row (for example top 19) this query has low performance for table loaninstallment with amount of records(10000000 R). any one can help me thanks for any help my code:

    select top 19 * from(select ROW_NUMBER()over (order by ID ) as rowNumber,* from BML.LoanInstallment where total_amount like '%80%') tbl

    L M 2 Replies Last reply
    0
    • M mhd sbt

      hi to all im face with low performance by below query in sql server 2008 any one can help me. my query is goon work when top has larg number but when top has less row (for example top 19) this query has low performance for table loaninstallment with amount of records(10000000 R). any one can help me thanks for any help my code:

      select top 19 * from(select ROW_NUMBER()over (order by ID ) as rowNumber,* from BML.LoanInstallment where total_amount like '%80%') tbl

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

      mehdi.sabet wrote:

      my query is goon work when top has larg number but when top has less row (for example top 19) this query has low performance for table loaninstallment with amount of records(10000000 R).

      ..caused by the ROW_NUMBER function. Do you need it? Is it "just" a way of numbering the records? If yes, select into a temp-table and add the ROW_NUMBER there.

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

      M 1 Reply Last reply
      0
      • M mhd sbt

        hi to all im face with low performance by below query in sql server 2008 any one can help me. my query is goon work when top has larg number but when top has less row (for example top 19) this query has low performance for table loaninstallment with amount of records(10000000 R). any one can help me thanks for any help my code:

        select top 19 * from(select ROW_NUMBER()over (order by ID ) as rowNumber,* from BML.LoanInstallment where total_amount like '%80%') tbl

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Additional to Eddies suggestion: Why is total amount stored as text or why are you doing a text operation on a numeric field '%80%' seems wrong!

        Never underestimate the power of human stupidity RAH

        M 1 Reply Last reply
        0
        • L Lost User

          mehdi.sabet wrote:

          my query is goon work when top has larg number but when top has less row (for example top 19) this query has low performance for table loaninstallment with amount of records(10000000 R).

          ..caused by the ROW_NUMBER function. Do you need it? Is it "just" a way of numbering the records? If yes, select into a temp-table and add the ROW_NUMBER there.

          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

          thankue for answer i change my query to this:

          create table #tblTemp(
          ID int,
          RowNumber int
          )
          insert into #tblTemp
          select ID,ROW_NUMBER() over(order by ID) RowNum from BML.LoanInstallment
          select top 19 * from(select payment_date,total_amount,BML.LoanInstallment.ID,RowNumber from BML.LoanInstallment
          inner join
          #tblTemp on #tblTemp.ID = BML.LoanInstallment.ID
          where total_amount like '%80%') tbl

          this run completed a large of second i think the reason of this is my where clause that i use like in this clause and if i remove it my query is ok and response in reasonable time. what you thinks ? thanks

          L 1 Reply Last reply
          0
          • M mhd sbt

            thankue for answer i change my query to this:

            create table #tblTemp(
            ID int,
            RowNumber int
            )
            insert into #tblTemp
            select ID,ROW_NUMBER() over(order by ID) RowNum from BML.LoanInstallment
            select top 19 * from(select payment_date,total_amount,BML.LoanInstallment.ID,RowNumber from BML.LoanInstallment
            inner join
            #tblTemp on #tblTemp.ID = BML.LoanInstallment.ID
            where total_amount like '%80%') tbl

            this run completed a large of second i think the reason of this is my where clause that i use like in this clause and if i remove it my query is ok and response in reasonable time. what you thinks ? thanks

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

            I think you should try it, and then thank Mycroft :)

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

            M 1 Reply Last reply
            0
            • M Mycroft Holmes

              Additional to Eddies suggestion: Why is total amount stored as text or why are you doing a text operation on a numeric field '%80%' seems wrong!

              Never underestimate the power of human stupidity RAH

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

              this where clause is an example my where claue is another clause that my field is not total amount for example for address or anything else .

              1 Reply Last reply
              0
              • L Lost User

                I think you should try it, and then thank Mycroft :)

                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
                #7

                thank you:)

                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