I see others have answered your question but I'm not sure I agree with them all. When you say "Do the $Sth->execute() read the entire table and put it into an array in memory?" if you are talking about what happens in Perl or the XS code DBD::ODBC uses the answer is no. In ODBC terms what happens (in this simplified pseudo code is like this):
you call $dbh->prepare:
SQLPrepare(select whatever from whatever);
you call $sth->execute
SQLDescribeParam(called per parameter and parameters bound with SQLB
+indParameter) - does not happen in your case as you haven't got any
SQLExecute
SQLNumResultCols(to find if there is a result-set and how many colum
+ns)
various calls to SQLDescribeCol and SQLColAttributes to find out abo
+ut the columns
you call $sth->fetchrow;
If the columns are not already bound:
SQLBindCol for each column
SQLFetch (one row requested from ODBC driver)
you call $sth->fetchrow;
SQLFetch (one row requested from ODBC driver)
What happens in the database and between the database and the ODBC driver is difficult to answer as it depends on the driver and database. For instance, with MS SQL Server using the TDS protocol then unless you've changed the default cursor, the database gathers all the rows and sends them down the socket and the driver reads whatever it decides (could be 1 row, could be multiple rows).
When you use fetchall_* DBI calls fetch repeatedly in the DBD and stores the rows.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|