对于大文件,SQLite非常慢

时间:2018-05-05 18:00:01

标签: sql database sqlite

我有一个21.5 GB的数据库文件,我正在尝试对数据进行一些查询,但它没有响应。它最终在没有任何结果的情况下处理查询。 即使是计算表中行数的简单查询也不起作用。

将查询限制为较小的数字时,它可以正常工作。像这样的东西

FROM ubuntu:14.04
# Install Java.
RUN \
  echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
  apt-get update && \
  apt-get upgrade -y && \
  apt-get install -y  software-properties-common && \
  add-apt-repository ppa:webupd8team/java -y && \
  apt-get update && \
  apt-get install -y oracle-java8-installer && \
  rm -rf /var/lib/apt/lists/* && \
  rm -rf /var/cache/oracle-jdk8-installer

# Define commonly used JAVA_HOME variable
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle

# get maven 3.2.2 and verify its checksum
RUN wget --no-verbose -O /tmp/apache-maven-3.2.2.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.2/binaries/apache-maven-3.2.2-bin.tar.gz; \
echo "87e5cc81bc4ab9b83986b3e77e6b3095 /tmp/apache-maven-3.2.2.tar.gz" | md5sum -c   
ARG BASE_URL=https://apache.osuosl.org/maven/ven-3/${MAVEN_VERSION}/binaries

# install maven
RUN tar xzf /tmp/apache-maven-3.2.2.tar.gz -C /opt/; \
  ln -s /opt/apache-maven-3.2.2 /opt/maven; \
  ln -s /opt/maven/bin/mvn /usr/local/bin; \
  rm -f /tmp/apache-maven-3.2.2.tar.gz
ENV MAVEN_HOME /opt/maven


# Install dependencies
RUN apt-get -y update  && \
    apt-get -yqq --no-install-recommends install bash git bzip2 curl unzip && \
    apt-get update

copy jenkins war file to the container
#ADD http://mirrors.jenkins.io/war-stable/2.107.3/jenkins.war /opt/jenkins.war
COPY jenkins.war /opt/jenkins.war
ENV JENKINS_HOME /jenkins

# configure the container to run jenkins, mapping container port 8080 to that host port
RUN mkdir /jenkins/
COPY proxy.xml /jenkins/proxy.xml
COPY config_updated.xml opt/config_updated.xml

USER root
ENV JENKINS_MIRROR http://mirrors.jenkins-ci.org

COPY settings.xml /usr/share/maven/conf/settings.xml
RUN mkdir /jenkins/plugins

COPY /jenkins.war /usr/share/jenkins/jenkins.war
RUN echo 2.107.1 > /jenkins/jenkins.install.UpgradeWizard.state
RUN echo 2.107.1 > /jenkins/jenkins.install.InstallUtil.lastExecVersion


#Install plugins
ENV JAVA_OPTS="-Xmx4096m"
ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false"

COPY /plugins.sh usr/local/bin/plugins.sh
COPY /plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/ref/plugins.txt
ENTRYPOINT ["java","-jar","/usr/share/jenkins/jenkins.war"]

问题是尝试对整个表执行查询时。它被卡住了。我想知道是否有任何优化我可以这样做,所以我可以查询整个数据集。

有人知道查询这么大文件的更好方法吗?

提前谢谢。

1 个答案:

答案 0 :(得分:1)

确保你做的一切正常!您使用的是预定义语句吗? * SQLITE 3.7.3

  1. 交易
  2. 预先陈述
  3. 应用这些设置(创建数据库后立即

    re.MULTILINE

  4. Question

    中的更多信息