![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've a large file of many SQL statements (for the purpose of populating). I've tried running this through mysql both (1) locally (but using TCP) and (2) remotely (connecting via a circuit created via the -L option of SSH). The latter is much slower. Note that my SSH connection is nowhere close to using the available bandwidth. I use it all the time for interactive logins, and I've never noticed a latency issue. When I use strace on the mysql process running remotely, I see slight pauses while in a read() apparently awaiting the response from the server. When I do the same on the mysql process running locally, I don't see these pauses. So...perhaps it's just latency that I don't normally notice, but which adds up in this case given the large number of statements - and therefore the large number of these little pauses. Is there anything I can do about it? |
|
One possibility would be to let the queries run asynchronously, where query N could run before the response to query N-1 had been received. As long as the queries ran in the proper order, that would be fine with me. Unfortunately, I don't see a way to achieve this. Any suggestions? Thanks...Andrew |
#3
| ||||
| ||||
|
|
I've a large file of many SQL statements (for the purpose of populating). I've tried running this through mysql both (1) locally (but using TCP) and (2) remotely (connecting via a circuit created via the -L option of SSH). |
|
Note that my SSH connection is nowhere close to using the available bandwidth. |
|
Is there anything I can do about it? |
|
One possibility would be to let the queries run asynchronously, where query N could run before the response to query N-1 had been received. |
#4
| ||||
| ||||
|
|
As others already said: SSH encrypts, optionally compresses and multiplexes packets between endpoints. This is slow. |
|
1. you can upload (scp) your SQL file to the remote machine and then load it there |
|
2. you can use netcat to open an unencrypted (fast) tunnel: remote: netcat -l -p 4711 | mysql -u... -p... local: cat sqlfile | netcat remote 4711 |
|
One possibility would be to let the queries run asynchronously, where query N could run before the response to query N-1 had been received. This will not work. The MySQL wire protocol is synchronous. The server will not accept a request packet before it has sent the last response packet. |
#5
| |||
| |||
|
|
2. you can use netcat to open an unencrypted (fast) tunnel: remote: netcat -l -p 4711 | mysql -u... -p... local: cat sqlfile | netcat remote 4711 |
#6
| |||
| |||
|
|
I'm running that test now. |
#7
| |||||||
| |||||||
|
|
I'm still running some tests, but two interesting cases stand out. Where mysql connects to a remote mysqld over an encrypting VPN (w/o that extra SSH I was imposing previously), it takes many hours. |
|
Where I simply cat the file through nc to another nc through that same VPN, where the destination nc is running on the same server that is running mysqld, and where the destination nc is connecting via TCP to mysqld, it takes an hour. |
|
So just moving the mysql "further away" (where distance is measured in terms of latency) slows the process. I'd guess that this is the result of the synchronous nature of the protocol, where reply N must be received by mysql before request N+1 is sent. |
|
I believe that an asynchronous approach would eliminate the delay as those round-trips could occur in parallel with the actual processing of queries. |
|
I could shift this to a more asynchronous approach by using multiple TCP connections. Has anyone done something like this? |
|
I don't even think a lot of parallelism is required to eliminate the cost imposed by the latency, since I believe the processing time is higher than the latency. |
|
Another idea I'm considering is making use of an additional daemon which would act in the role, more or less, of the receiving nc above. It would basically provide a "bulk multiquery service". But hasn't this been done before? |
![]() |
| Thread Tools | |
| Display Modes | |
| |