Dump Database to Memory

Dump Database to Memory

Postby b.szabo » Mon 03 Mar 2008 05:23

Hi,

I need some help on MySQLDump.
MySQL Dump is working properly into, file. I want to make the option available to dump the database into a memory stream.
Could you send me some vb code how can I backup and retrieve into memory.
What are the limits, restricitons etc.

Thanks,
Barnabás
b.szabo
 
Posts: 14
Joined: Wed 04 Jul 2007 05:50

Postby Alexey.mdr » Mon 03 Mar 2008 11:21

Well, practically it looks pretty much the same:
Code: Select all
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        MySqlConnection1.Open()
        MySqlDump1.Connection = MySqlConnection1
        MySqlDump1.DisableKeys = True
        MySqlDump1.IncludeDrop = True
        MySqlDump1.GenerateHeader = True
        MySqlDump1.IncludeLock = True
        MySqlDump1.IncludeDatabase = True
        MySqlDump1.UseExtSyntax = True
        MySqlDump1.Backup()

        Dim a As String
        a = MySqlDump1.DumpText  'here in debug mode you can see the generated dump text


        MySqlDump1.Restore()
        MySqlConnection1.Close()

    End Sub
End Class

I would recommend using dump of a database into a memory stream if the size of the
database isn't large and you do not need a dump file on your hard drive.
But be aware you might face a System.OutOfMemory exception, when there's no memory available.
It depends on the physical memory size and its current load.
Alexey.mdr
 
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Postby b.szabo » Tue 04 Mar 2008 05:40

Thanks Alexey,

I have another proglem. I'm using the dump progress to set the position of the progressbar. THe problem is that the maxprogress is only for a table. When I set the position it goes up 100% and then starts again, so many time as how many are in the database. I want to know the exact row count for the mysqldump to the whole database, and inside that what is the current position. Not inside a table.

Could you help me on this.

Thanks,
Barnabás
b.szabo
 
Posts: 14
Joined: Wed 04 Jul 2007 05:50

Postby Alexey.mdr » Tue 04 Mar 2008 13:09

There are two cases:
1) Dump.Restore() – use your scheme. It should work perfectly.
2) Dump.Backup() - the situation is more complicated. We do not provide provide an accurate estimating mechanism.
Because it's not clear how we should estimate database objects.
What if you have one thousand tables and many of them are small, but several have, say, one million records.
Plus there are views, stored procedures etc.
As you can see it's quite hard to make a relatively correct estimate for general cases.
I suggest using two progress bars.
One of the bars could be linked to the current database object progress.
You need to organise the behaviour of the second progress bar using your own expert knowledge about the database objects.
Alexey.mdr
 
Posts: 729
Joined: Thu 13 Dec 2007 10:24


Return to dotConnect for MySQL