SPROC vs Inline Times.

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default SPROC vs Inline Times.

    Hey guys. I have a page which is generating fairly lengthly reports. I
    understand most of the parsing time is being created from the many tr and td's
    being created. I've thought about converting to divs, but don't think it will
    help all that much either.

    Anyway here is my question. While I'm trying to follow "best practice" and
    seperate out the Data layer from the Application layer I noticed my proc taking
    significantly longer to execute then my inline query.

    This query expects 3 parameters. I've hardcoded them in the query for this
    example.

    Here is my inline query - Takes 31ms to execute and bring me 2900 results.

    SELECT a.brokernumber,
    rtrim(a.bound_sym) + ' ' + rtrim(a.bound_pol) + ' ' + rtrim(a.bound_mod) as
    policy,
    a.nameinsured,
    a.quotetype,
    a.dateeffective,
    a.bound_premium,
    a.producername,
    a.controllingagent,
    a.uwaction,
    a.actionreason,
    b.quoteaction,
    c.declinereason,
    d.name
    FROM q_temp_tbl a
    LEFT JOIN q_action_tbl b ON a.uwaction=b.action_id
    LEFT JOIN q_actionreason_tbl c ON a.actionreason=c.decline_id
    LEFT JOIN q_brokerinfo_tbl d ON a.brokernumber = d.brokernumber
    WHERE DateEffective >= 1/1/2003
    AND DateEffective <= 9/1/2005
    AND Lob_ID= 3
    ORDER BY a.brokernumber,dateeffective


    My SPROC is essentially the same thing with the 3 parameters as @vars. Here is
    how I'm calling it. My SPROC takes 700ms

    <cfstoredproc procedure="QT_Report_Agency" datasource="#application.dsn#"
    returncode="Yes">
    <cfprocparam type="In" cfsqltype="CF_SQL_DATE" dbvarname="DateStart"
    value="#CreateODBCDateTime(starting)#" null="No">
    <cfprocparam type="In" cfsqltype="CF_SQL_DATE" dbvarname="DateEnd"
    value="#CreateODBCDateTime(enddate)#" null="No">
    <cfprocparam type="In" cfsqltype="CF_SQL_INTEGER" dbvarname="Lob_ID"
    value="#Lob_ID#" null="No">
    <cfprocresult name="rsQuote">
    </cfstoredproc>

    Inline: 31ms, SPROC: 700ms - I've refreshed, tried differenet machines, etc.
    I'd like to keep my queries in SPROCS, but that's a pretty big % difference.

    Any thoughts?

    dj shane Guest

  2. Similar Questions and Discussions

    1. Looping a list in SQL 2000 SPROC
      Hey guys, just trying to learn something new today and wanted to convert one of my cf pages to a sproc. This page just sets up security for the...
    2. SPROC Question, what am I doing wrong?
      Here's my SPROC. CREATE PROCEDURE UpdateHits AS DECLARE @Result AS int DECLARE @ResultDate AS datetime SET @Result = (SELECT HitCount FROM...
    3. sproc in DW asp.net
      I am trying to create a dataset from a stored procedure. I am using the stored procedure dialog box but when I put in the values I get an...
    4. [PHP-DEV] [PATCH] inline -> static inline
      On Fri, 15 Aug 2003, Jason Greene wrote: Thanks, I have applied the patch. The CVS reorg did not affect karma assignment. - Sascha
    5. SPROC parameters
      Hi, I'm putting together a Stored Procedure. I need to build a select statement that grabs two column values from a table (single row) and then...
  3. #2

    Default Re: SPROC vs Inline Times.

    I should mention, CF is running on the Same box as MSSQL2000 (Not ideal, but it's what I have to work with).
    dj shane Guest

  4. #3

    Default Re: SPROC vs Inline Times.

    That's probably a huge portion of the problem.... CF is going to glob a lot of
    memory and not leave a lot for SQL to work with.

    Also, are you using the same variables every time? CF will cache your query
    to a degree regardless of whether you've used the cachedwitnin parameter, but
    stored procs can't be cached at all. Try running your test but varying the
    variables each time. Put the inline query and the stored proc on the same page
    and compare your results then.

    Stored procs are valuable as much for security and portability as much as for
    speed. That said, in a more robust environment they'd almost undoubtedly be
    considerably faster (dedicated RDBMS).

    JonathanBigelow Guest

  5. #4

    Default Re: SPROC vs Inline Times.

    PS. "Varying the variables"? Haha, try saying that 10 times as fast as you can...
    JonathanBigelow Guest

  6. #5

    Default Re: SPROC vs Inline Times.

    That is exactly how I was doing my optimization is on the same page. Was trying BETWEEN vs the <= and => as well. Noticed a slight difference. Understand the portability and security, thanks.
    dj shane Guest

  7. #6

    Default Re: SPROC vs Inline Times.

    With further testing I verified both the normal query and SPROC code run in
    less then a second in Query Analyzer. I believe the major contributing factors
    in the slowness of these reports are:

    1. Returning 15 columns x 3,000 records (makes for plenty of td's and tr's)
    and yes I tried a clean div version and it did nothing except make the code
    look prettier.

    2. The fact SQL and CF are on the same box. Although this is a powerful box,
    perhaps someone can fill me on on the latency issues with this type of
    architecture.

    dj shane Guest

  8. #7

    Default Re: SPROC vs Inline Times.

    Shared memory + shared processor + shared disks = latency issues up the ying
    yang.

    CF makes a request to SQL, thread hangs open waiting for SQL to respond. SQL
    receives request from CF, has to grab memory that CF is already using a grip
    of. SQL has to process the request and read data from disk (hopefully you're
    not at a point where your memory is low enough that you're using the pagefile
    at all). SQL can return the request and close it's thread. CF still has it's
    thread hanging open until it's done processing the results from SQL.

    Now, on a busy site, multiply that by 30 - 40 concurrent requests and you're
    box aint gonna be too happy.

    I love CF, but frankly, its performance on busy sites with a lot of downstream
    requests (to SQL, webservices, CFHTTP, etc.) sucks, especially if, god forbid,
    something happens downstream and CF has to wait a little bit for a response.
    Ever seen CF glob onto 400MB + of memory? A loaded, busy SQL server will
    easily grab another 300MB. Add in IIS and other miscellaneous Windows crap and
    you need at least a gig of RAM just to squeak by.


    JonathanBigelow Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139