How to expedite VB.net database searches / Access97

Asked

Viewed 449 times

0

Use a query searching in 3 different tables, returning this query attribute in a Datatable that will fill a Datagridview.

The problem is that the search itself, this a little time, I used the TOP as a limiter but still takes some time. I use a Access database 97, all indexed tables.

Well, I wonder if there is any way I can use a cache to expedite this query, or what I can improve on my query, this delay is sent to me.

Follows the code:

SELECT TOP 10 Pedidos.Número, Clientes.RazaoSocial As [Cliente], vendedores.nome As [Vendedor], Pedidos.Data As [Data], 
Format(Pedidos.Valor, '###,##0.00') As [VrPedido], Pedidos.Flag As [Flag], Pedidos.Status As [Status],Cliente As [codcli], Vendedor As [codVend] 

FROM Pedidos, vendedores, Clientes 

WHERE Lançamento = 0 And Pedidos.vendedor = Vendedores.código And Clientes.CodigoCliente = Pedidos.Cliente ORDER BY data desc, número desc

Filling in the Datagrid:

DataGridView1.DataSource = Nothing
da = New OleDbDataAdapter(MySQL, Conexao)
dt = New DataTable
da.Fill(dt)
Me.DataGridView1.DataSource = dt
  • I just found your code strange: da = New OleDbDataAdapter(MySQL, Conexao)... Mysql or Access?

  • Mysql, is only the variable that receives the SELECT query

2 answers

1

MS Access is not a real database management system and has no way to achieve the same performance as a SGBD. In addition to other limitations such as the maximum file size of 1Gb .mdb (version 97).

My answer is: use MySQL, PostGres, MS SQL, NoSQL, etc..

If this is not an option, the link below has several techniques to improve the performance of a Base Access:

http://www.fmsinc.com/microsoftaccess/performance.html

  • Only one detail, by definition Access is a DBMS, but for a specific niche (use in personal makeup).

  • SGBDR is not by definition SGBD: https://pt.wikipedia.org/wiki/Sistema_de_management_de_banco_de_data#Exemplos_de_sgbds

  • All you cited are Dbms using the relational model: https://en.wikipedia.org/wiki/Relational_database_management_system. So a DBMS is not a DBMS ?

  • If I use a Sqlserver, what should I do to expedite this query? !

0

Have you tried changing your query to one INNER JOIN ?

SELECT TOP 10 Pedidos.Número, Clientes.RazaoSocial As [Cliente], vendedores.nome As [Vendedor], Pedidos.Data As [Data], 
Format(Pedidos.Valor, '###,##0.00') As [VrPedido], Pedidos.Flag As [Flag], Pedidos.Status As [Status],Cliente As [codcli], Vendedor As [codVend] 
FROM Pedidos
INNER JOIN vendedores ON Pedidos.vendedor = Vendedores.código
INNER JOIN Clientes ON Clientes.CodigoCliente = Pedidos.Cliente
ORDER BY data desc, número desc

Withdraw the ORDER BY can improve the performance of query also.

Other points that may affect performance:

  • Your tables have a primary key?
  • Are the indexes set? (Not your case)
  • There are no duplicate lines?
  • ORDER BY actually delayed the query, but I need to sort the 2 columns in descending order.

  • If these columns have indexes in the layout you use on ORDER BY can get faster.

  • I have index in both and still slow.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.