If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Replication: Subsequent queries from different slaves

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-05-07, 22:10
screenmates screenmates is offline
Registered User
 
Join Date: Jul 2005
Posts: 63
Replication: Subsequent queries from different slaves

Hi All,

If I insert a row into one db, is it possible to do fetch the last inserted ID from another slave db?

Similarly, if I fetch multiple rows using sql_calc_found_rows from one db, is it possible to SELECT FOUND_ROWS() from another slave db?

TIA
Reply With Quote
  #2 (permalink)  
Old 07-06-07, 05:34
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Not entirely sure if this answers your question but have you ever tried something like this;
Code:
USE MyDatabase1
GO

SELECT * FROM MyTable

USE MyDatabase2
GO

SELECT * FROM MyOtherTable
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 07-20-07, 00:30
screenmates screenmates is offline
Registered User
 
Join Date: Jul 2005
Posts: 63
What you are suggesting is to use a different database within the same instance (connection). I was asking about using a different instance (multiple slaves in a replication).

Thanks, anyway.
Reply With Quote
  #4 (permalink)  
Old 07-20-07, 05:18
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
How are you calling fetch last inserted id? My understanding is that this function is limited to returning the last row id inserted by a program. Of course your program doesn't run on the master which means the internal setting of the slave doesn't have the same last id inserted information.

In answer to your FOUND_ROWS() question.... no. If you perform the query on one database and then do SELECT FOUND_ROWS() on another you're not going to get the right result (if one at all). Try it and see.

n.b. there is a possibility I am wrong on all counts. These answers are based on research I have done in the past and NOT testing I have performed.
Reply With Quote
  #5 (permalink)  
Old 07-20-07, 06:49
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
The other question is why do you want to do this?

You might run a number of different instances to create a database "farm" so multiplying the throughput of your whole system by allowing other users to run their queries on different instances. I don't understand why you'd want to connect to more than one instance at a time though.

If it's just to check that the replication is still happening then there must be better ways of checking things are still working.

Mike
Reply With Quote
  #6 (permalink)  
Old 07-24-07, 07:17
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
It's occured to me that in the instance of running an insert query, it's always going to be on the master server (unless you're inserting into slaves, not advisable). Which means the lifespan of the program (if web based) is going to be limited to the connection you've created to the master. So, only the master is going to give you the last_insert_id . You could change sql connection mid program run, but why would you want to?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On