Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow UNIX domain socket #60

Closed
Kijewski opened this issue Mar 16, 2011 · 5 comments
Closed

Allow UNIX domain socket #60

Kijewski opened this issue Mar 16, 2011 · 5 comments

Comments

@Kijewski
Copy link
Contributor

Hi,

I found using "/var/run/mysqld/mysqld.sock" being 10 to 20 % faster than a local TCP connection. Esp. connecting is almost immediately.

I'd suggest setting host = null and setting port appropriately (if different from default) should open a local IPC connection. My diffs and it's follow up would do the trick.

I guess windows' named pipes should be usable the same way. Having no windows installation, I cannot help you with that. ;)

Greetings
René

@felixge
Copy link
Collaborator

felixge commented Mar 16, 2011

Thanks for the patches! A few things:

  • Please use pull requests and isolated feature branches (your master also has other stuff in it), makes it much easier for me to review stuff : ).
  • I don't know if this should be in there: Client.SOCKET_PATH = '/var/run/mysqld/mysqld.sock'; Seems like that's just specific to your system, no?
  • Wasn't it possible to do this already by setting port = '/some/socket.sock' ? I'm not saying there shouldn't be an explicit property for it, but I was under the impression that this was already working.
  • When adding a property to an object (self.unixSocket), always add it in the constructor as well. Otherwise future-me is going to have a hard time reasoning about the state and configuration of the Client object.

--fg

--fg

@Kijewski
Copy link
Contributor Author

  • Sorry, I'm quite new to Github (and Git for that matter ...). I'll try to learn branching in future. ;)
  • In mysql_version.h MYSQL_UNIX_ADDR in defined as "/var/run/mysqld/mysqld.sock". The path conforms the Filesystem Hierarchy Standard, which Linux and *BSD conforms to. So likely even Mac OSX will have the socket at this path.
  • Yes it was already possible. I only want to suggest to promote this feature as it promises a remarkable performance gain on low and high frequented web applications.
  • You're right. On second thought I'd discourage adding a new parameter. The name port for the socket path should be pretty sufficient as is.

My suggestions collapse to proposing making using the unix socket default.

Regards, René

@felixge
Copy link
Collaborator

felixge commented Mar 17, 2011

My suggestions collapse to proposing making using the unix socket default.

Hm, I think connecting to localhost:3306 is more common by default, no? But I think I'd like to see a patch that allows:

// Use default: /var/run/mysqld/mysqld.sock
client.socket = true;

Or

client.socket = '/my/custom.sock';

--fg

PS: I'll be on vacation until the 29th, so I won't have a chance to merge anything until then.

@dresende
Copy link
Collaborator

host = whatever; port = "/path/to/mysqld.sock" seems to work perfectly

@felixge
Copy link
Collaborator

felixge commented May 15, 2012

Use what @dresende for 0.9.x. 2.0.0 now supports this explicitly: 89dd8ab

@felixge felixge closed this as completed May 15, 2012
dveeden pushed a commit to dveeden/mysql that referenced this issue Jan 31, 2023
myspar pushed a commit to myspar/mysql that referenced this issue Dec 21, 2023
myspar pushed a commit to myspar/mysql that referenced this issue Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants