in reply to bind_columns OR fetchall_arrayref

hi, thanks everyone for replying.

i dont have too many fancy html, just the plain table tags. no images, text, natta. just table tags. :)

i'm fetching about 2200 rows, with 10 columns, 1 table and it will take 12-16 seconds to load (i'm using a cable modem) up the html and for it to be displayed on the browser.

-AT- first i was using fetchall_arrayref (until i learned that this way is the slowest and causes the most memory strain on the webserver.

-THEN- i decided to use bind_columns with fetch. I too also heard this way was the best from two of the tutorials on here (Files and Databases).

-HOWEVER- whether using either way, BOTH fetchall-arrayref and bind_columns methods take about the same amount of time to display the results on the browser, again around 12-16 seconds.

That is mainly why I decided to come here to post a question relating to this topic. I'm figuring bind_columns is the fastest/efficient way to do the job I'm trying to do, and that it takes the same amount of time as fetchall_arrayref because its on the browser end, therefore it still needs to wait for the '/table' tag.

one question that I now have-
would placing a max row option or a limit in the sql improve the efficiency/speed?

thanks
=perleager=

Replies are listed 'Best First'.
Re^2: bind_columns OR fetchall_arrayref
by punkish (Priest) on Jan 04, 2005 at 23:48 UTC
    once again you are asking a classically wrong question. From your own observation
    -HOWEVER- whether using either way, BOTH fetchall-arrayref and bind_columns methods take about the same amount of time to display the results on the browser, again around 12-16 seconds.

    So, why not use Benchmark and find out if one or the other is significantly faster? Either way, you are getting the same results. And, either way, you are likely to discover that getting the data from the db is probably just a fraction of a second or just a wee bit more. Most of the time is probably spent in assembling the html, sending it via the server, and the cable modem, up to you, and then rendering it on your computer. So, even if you manage to speed up a 200 microsecond job by 500% (the db work), you will still be stuck with 11-15 seconds of other grunt work.

    My advice -- use Benchmark, adjust, and then quit worrying, or else, put a throttle on your max rows returned and page the results n at a time.

    Good luck.

Re^2: bind_columns OR fetchall_arrayref
by foil (Sexton) on Jan 05, 2005 at 00:49 UTC
    Cable modem ....?? .... This is your garden variety Comcast or Verizon account from your home ?? .. I don't think anybody gets great upload speed from a web server in that situation (I don't) ... you have to pay $ to get uploadspeed .. Does page load faster locally ? ( not through modem ??) ... bottleneck probably is not your code
Re^2: bind_columns OR fetchall_arrayref
by Thilosophy (Curate) on Jan 05, 2005 at 02:13 UTC
    one question that I now have- would placing a max row option or a limit in the sql improve the efficiency/speed?

    The bottleneck here is not fetching the data from the DB, but sending the resulting HTML to the browser and rendering it there. Limiting the number of rows you fetch will reduce the size of the HTML and make it a lot faster. Accessing the DB will also be faster, but if that takes 0.2 secs instead of 0.3 secs is not relevant anyway.

    So if you can live with the page displaying only a part of the data (at least at once, you can have many pages) go for it.