PDA

View Full Version : very slow access to +100 Mb .mdb file with ODBC driver



GoranSimunic
8th March 2016, 14:58
Hi to all,

do you have a clue why counting 190 tables in mdb lasts for over a minute and half,
and time to closing connection lasts almost 2 minutes from reading the tables?

mdb file which is read is 120 megs!

this is part of code,
.cpp and .h file attached...


QStringList list = db.tables(QSql::Tables);
//qDebug() << "Views list\n " << list.join(",").toLocal8Bit().data() << "\n";
qDebug() << list.count();
if(db.tables().isEmpty()){
qDebug() << "list empty ";
}
else {
qDebug() << "list not empty";
}


.h file


#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QtSql/QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QStringList>


namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT

public:
explicit Widget(QWidget *parent = 0);
~Widget();

public:
QString vrijeme;
QString vrijemeKraj;
QSqlDatabase db;
QSqlQuery sqlTrazi;
QStringList list;

bool conOpen(){

db=QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=D:/Instalacija/syn/Storage.mdb");

if(!db.open())
{
//qDebug() << "Database Error" << db.lastError(); //<< db.lastError().text();
return false;
}
else
{
return true;
}
}
void closeConnection(){
db.close();
}
private:
Ui::Widget *ui;
//QSqlDatabase db;
};

#endif // WIDGET_H

.cpp file

#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QTime>

Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
qDebug() << QSqlDatabase::drivers();
QVector<QString> lista; //this is not used at the moment


if(!conOpen()){
qDebug() << "konekcija nije uspjela " << "\n"; //not connected
}
else {
qDebug() << "konekcija je uspješna"; //connected...
}

vrijeme = QTime::currentTime().toString("hh:mm:ss:zzz");
qDebug() << vrijeme << "\n";

QStringList list = db.tables(QSql::Tables);
qDebug() << list.count();
if(db.tables().isEmpty()){
qDebug() << "list empty - lista je prazna";
}
else {
qDebug() << "list not empty - Lista nije prazna?";
}
Widget::closeConnection();
vrijemeKraj = QTime::currentTime().toString("hh:mm:ss:zzz");
qDebug() << vrijemeKraj << "\n";
qDebug() << "connection closed-konekcija zatvorena ";

}

Widget::~Widget()
{
delete ui;
}

d_stranz
8th March 2016, 15:09
I can't answer your question, but PLEASE use CODE tags when you post source code.

There are two ways to do this:

1 - Manually insert the tags before and after your code. Put [ CODE] before the source code, and [ /CODE] after it. (Remove the space I have placed after the "[" - it's there to prevent the forum from converting the text into an actual CODE tag).

2 - Click "Go advanced" when you start to post. Click the "#" icon, which will insert the tags. Paste your code between them.

As it stands now, the code you post is unreadable and it makes it extremely hard to see what is wrong.

GoranSimunic
8th March 2016, 18:55
Hi,
thanks for editing this instead of me. I will be careful in further posts.

jefftee
9th March 2016, 04:12
Is your D drive a local drive or mapped network drive?

GoranSimunic
9th March 2016, 17:35
Yes it is my local drive, (I use for tesing), but also yes, I would like to do some SELECT (and update) statement to that same table on mapped network drive on Windows small bussines server 2011.
As user I have access to to read and write to that mapped disk (e.g. X:/)

GoranSimunic
17th March 2016, 00:00
For slow reading of 120 Mb mdb file I've found that this problem seems to be slow PC/and disk

1. HP 650 (I3 8Gb ram 5400HD) Qt 5.5.1 32 bit MinGW - over 2 minutes connect, query close connection (list 200 tables),
2. vs Dell 5520 I5 8Gb ram 5400 HD, Qt 5.3.0 32 bit MinGW, 66 miliseconds connect, query, close connection(list 200 tables)

I don't know how such difference is possible.