简体   繁体   English

jdbc sqlite性能-查询异常慢

[英]jdbc sqlite performance - queries exceptionally slow

I'm trying to provide users of my java-based software with the option to use sqlite instead the default MySQL because some users don't know what MySQL is, or how to install, or don't want to. 我试图为基于Java的软件的用户提供使用sqlite而不是默认MySQL的选项,因为有些用户不知道MySQL是什么,如何安装或不想。

I've got everything working fine with sqlite but the query times are extremely slow. 我已经使用sqlite一切正常,但查询时间非常慢。 A SELECT query, from within java using jdbc takes at least three times as long to return results than when using MySQL. 使用jdbc在java中进行SELECT查询返回结果的时间至少是使用MySQL的三倍。

However, the same query run directly in the sqlite console works within milliseconds. 但是,直接在sqlite控制台中运行的同一查询将在几毫秒内运行。 It's got to the be the jdbc connection that's causing the slowdown. 必须是导致减速的jdbc连接。

Any suggestions on what I can do to improve the speed? 关于如何提高速度有什么建议吗? I've heard about replacing the drivers with the Xerial versions but am not certain how to do that. 我听说过要用Xerial版本替换驱动程序,但不确定如何做到这一点。 I'd do that for testing but that's obviously something I doubt we can ask our users to do - if they're against installing mysql they're not going to want to switch drivers for sqlite... 我会这样做以进行测试,但是显然这是我怀疑我们可以要求我们的用户这样做的事情-如果他们反对安装mysql,那么他们就不想为sqlite切换驱动程序...

Your driver should be typically installed with your program distribution. 您的驱动程序通常应与程序分发一起安装。 (the same way you wrap sqlite with your application) This way the driver is transparant for your user (he/she doesn't know what happens behind the scenes) and you can use the other driver. (与使用应用程序包装sqlite的方法相同),这种驱动程序对于您的用户是透明的(他/她不知道幕后发生的事情),并且您可以使用其他驱动程序。

It seems a bit strange that a driver that is bundled with a certain rdbms would be exceptionally slow btw. 与某些rdbms捆绑在一起的驱动程序的运行速度异常慢似乎有点奇怪。 You could try going through the sqlite logs to see what happens behind the scenes. 您可以尝试查看sqlite日志,以了解幕后发生的情况。 (I would even recommend it) (我什至会推荐)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM