Re: whoa!

2009-03-01 Thread Andy Shellam

Hi PJ,

By the look of your language you're using PHP to communicate with 
MySQL.  Is this assumption correct?


If so you don't need to use that section of the manual - that's the C 
API for programmers developing applications in the C or C++ language.  
PHP is a whole different ball game and you're right - mysql_store_result 
would do nothing for you (PHP wouldn't even recognise it as a function.)


If you are using PHP, you'd be better off looking at the PHP manual 
instead - http://uk3.php.net/mysql.


Hope this helps,

Andy

PJ wrote:

Hi Andy,
I still don't understand what is the purpose of calling
mysql_store_result().

I got what I needed this way:
  $text = Joe of Egypt;
  $sql = SELECT title FROM book WHERE title LIKE '$text';
  $result = mysql_query($sql);
if (mysql_num_rows($result)  0) {
echo (We have results);
}
   
else  {echo (Empty!);

  }
And if I change the Joe of Egypt to Cleopatra of Egypt the return is
correct also.
So why would I need mysql_store_result()? Don't forget, I'm using a
SELECT query, not INSERT, UPDATE or whatever the third was... :-)
PJ

Did I do something wrong?


Andy Shellam wrote:
  

Hi PJ,

Having been a C programmer for a while this makes perfect sense to
me.  You call mysql_(real)_query to execute the query and get the
results from the server.  Because the MySQL library doesn't know when
you've finished with the result-set, you have to tell it to write the
results to memory (mysql_store_result.)  This can then be read using
mysql_num_rows and other data retrieval functions.

This sentence in the manual makes this clear:

After you have called mysql_store_result() and gotten back a result
that isn't a null pointer, you can call mysql_num_rows() to find out
how many rows are in the result set.

When you're finished with the result-set you can then use
mysql_free_result to release the memory allocated by the library.

What difficulties are you having with error checking?  Most MySQL
functions return NULL if the operation fails - mysql_real_connect,
mysql_store_result etc.  Others return non-zero, like
mysql_real_query.  All the function documentation in the manual gives
the return codes and how to tell if a call failed.

Personally I've found the MySQL manual the best of any documentation
for systems we use, although I agree an example of a simple
client/query would have been useful.

Regards,
Andy

PJ wrote:


What is this supposed to mean from the manual:
The use of |mysql_num_rows()|
http://dev.mysql.com/doc/refman/5.0/en/mysql-num-rows.html depends on
whether you use |mysql_store_result()|
http://dev.mysql.com/doc/refman/5.0/en/mysql-store-result.html or
|mysql_use_result()|
http://dev.mysql.com/doc/refman/5.0/en/mysql-use-result.html to return
the result set
|mysql_num_rows()|
http://dev.mysql.com/doc/refman/5.0/en/mysql-num-rows.html is intended
for use with statements that return a result set, such as |SELECT|
http://dev.mysql.com/doc/refman/5.0/en/select.html.
Does this mean you have to use
mysql_store_result() before using mysql_num_rows() ? kind of doesn't
make sense to have to do that. And there are no clear cut examples or
explanations...
I do not wish to piss-and-moan but I do find that there is a lot to be
desired in the manual; things that are very ;contradictory and/ or
unclear and certainly lacking in examples.

And please, somebody guide me to some tutorial or something where I can
learn to set up proper error checking so you guys don't have to listen
to my problems. :'(
  
  



  


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: MyISAM large tables and indexes managing problems

2009-03-01 Thread Baron Schwartz
Claudio,

http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/

Your mileage may vary, use at your own risk, etc.

Basically: convince MySQL that the indexes have already been built but
need to be repaired, then run REPAIR TABLE.  As long as the index is
non-unique, this can be done by sort.  In your case, the index
(PRIMARY) is unique, so you'll need to see if you can work around that
somehow.  Maybe you can create it under another name as non-unique,
build it, then swap it and the .frm file out.  Have fun.

This is the only option I see for you, but maybe there are others.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: MyISAM large tables and indexes managing problems

2009-03-01 Thread Claudio Nanni

Hi Baron,
I need to try some trick like that, a sort of offline index building.
Luckily I have a slave on that is basically a backup server.
Tomorrow I am going to play more with the dude.
Do you think that there would be any improvement in converting the table 
to InnoDB

forcing to use multiple files as tablespace?

Thanks
Claudio
Baron Schwartz wrote:

Claudio,

http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/

Your mileage may vary, use at your own risk, etc.

Basically: convince MySQL that the indexes have already been built but
need to be repaired, then run REPAIR TABLE.  As long as the index is
non-unique, this can be done by sort.  In your case, the index
(PRIMARY) is unique, so you'll need to see if you can work around that
somehow.  Maybe you can create it under another name as non-unique,
build it, then swap it and the .frm file out.  Have fun.

This is the only option I see for you, but maybe there are others.

  



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: MyISAM large tables and indexes managing problems

2009-03-01 Thread Brent Baisley
Be careful with using InnoDB with large tables. Performance drops  
quickly and quite a bit once the size exceeds your RAM capabilities.



On Mar 1, 2009, at 3:41 PM, Claudio Nanni wrote:


Hi Baron,
I need to try some trick like that, a sort of offline index building.
Luckily I have a slave on that is basically a backup server.
Tomorrow I am going to play more with the dude.
Do you think that there would be any improvement in converting the  
table to InnoDB

forcing to use multiple files as tablespace?

Thanks
Claudio
Baron Schwartz wrote:

Claudio,

http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/

Your mileage may vary, use at your own risk, etc.

Basically: convince MySQL that the indexes have already been built  
but

need to be repaired, then run REPAIR TABLE.  As long as the index is
non-unique, this can be done by sort.  In your case, the index
(PRIMARY) is unique, so you'll need to see if you can work around  
that

somehow.  Maybe you can create it under another name as non-unique,
build it, then swap it and the .frm file out.  Have fun.

This is the only option I see for you, but maybe there are others.







--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org