Re: Arraylist.remove problem?? Please help.




"Extremest" wrote...

[snipped things I'm jealous of...]

I know that the big slow down for it is the loop.
so if the group thing can become a reality
I know it will speed it up big time.

I have only glanced on this thread before, so I don't think I have followed
all intricate details on what you want to do, but when you say that "the big
slow down for it is the loop", I looked at it, and saw some curious things.

Why are you opening and closing the connection so many times?

Network access is costly, even if it's only on the local machine.

And from what I understand, you use the same connection string for both
"conn" and "connu", so I don't see the point in having both.

Just to illustrate, I have hastily made some alterations in your "Main" and
"getheaders", which "should" work more efficiently.



static void Main(string[] args)
{
while (numbfound > 0)
{
numbfound = 0;

// Open the connection only one time for the loop

conn.ConnectionString = myConnectionString;
conn.Open();
cmd.Connection = conn;
cmdu.Connection = conn;

for (int x = 0; x < groups.Length; x++)
{
table = reg.Replace(groups[x], "");
group = groups[x];
getheaders();
find();
master.Clear();
prepared = false;
}

// And then we close it...

conn.Close();
Console.WriteLine(numbfound);
}
}

static void getheaders()
{
// No need to open a new connection, as conn and cmd are static

cmd.CommandText =
"select * from " + table +
" where subject like '%(%/%)%'" +
" and subject like '%\"%\"%' limit 400000";

MySql.Data.MySqlClient.MySqlDataReader reader;
reader = cmd.ExecuteReader();
master = new ArrayList();
while (reader.Read())
{
Header h = new Header(reader.GetValue(0).ToString(),
reader.GetValue(1).ToString(), reader.GetValue(3).ToString(),
reader.GetValue(2).ToString(), reader.GetValue(4).ToString(),
reader.GetValue(5).ToString());
master.Add(h);
}
reader.Close();
}

----------------------------------

There are probably many other things to make it faster too,
but these were some obvious ones...

/// Bjorn A


.



Relevant Pages

  • Re: Arraylist.remove problem?? Please help.
    ... ok tried to do that and for some reason it can't open the reader now. ... Bjorn Abelli wrote: ... you use the same connection string for both ... cmdu.Connection = conn; ...
    (microsoft.public.dotnet.languages.csharp)
  • Three Phases To Email Sensitivity
    ... the associationphase, the connection phase, and the ... They should have the right words thatthe reader can transform back ... When writing your response, you willwant to make ... If the topic is about apples, you donot want to add an orange ...
    (comp.lang.vhdl)
  • snd-hda-intel Codec: IDT 92HD73E1X5 support in lenny
    ... Amp-In caps: N/A ... Pincap 0x0000173f: IN OUT HP Detect Trigger ImpSense ... Conn = 1/8, Color = Green ... Connection: 6 ...
    (Debian-User)
  • Re: garbage collection
    ... You can not return reader after the connection is closed. ... But to return a dataReader you need to keep the connection open. ... Also, If your application>> doesnt allow database connection pooling, you need to dispose your> database ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: ODBC driver for SQL Server 2005 doesnt allow binding SELECT N
    ... the ODBC driver for SQL Server doesn't allow binding "SELECT ... static void Fini(p_odbc_host host) ... ret = SQLDriverConnect(conn->dbc, ... conn = NULL; ...
    (microsoft.public.data.odbc)

Loading