Re: Arraylist.remove problem?? Please help.
- From: "Bjorn Abelli" <bjorn_abelli@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 15 Jun 2006 00:46:36 +0200
"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
.
- Follow-Ups:
- Re: Arraylist.remove problem?? Please help.
- From: Extremest
- Re: Arraylist.remove problem?? Please help.
- References:
- Re: Arraylist.remove problem?? Please help.
- From: Bjorn Abelli
- Re: Arraylist.remove problem?? Please help.
- From: Extremest
- Re: Arraylist.remove problem?? Please help.
- From: Bruce Wood
- Re: Arraylist.remove problem?? Please help.
- From: Extremest
- Re: Arraylist.remove problem?? Please help.
- From: Extremest
- Re: Arraylist.remove problem?? Please help.
- From: Extremest
- Re: Arraylist.remove problem?? Please help.
- From: Bruce Wood
- Re: Arraylist.remove problem?? Please help.
- From: Extremest
- Re: Arraylist.remove problem?? Please help.
- From: Bruce Wood
- Re: Arraylist.remove problem?? Please help.
- From: Extremest
- Re: Arraylist.remove problem?? Please help.
- From: Bruce Wood
- Re: Arraylist.remove problem?? Please help.
- From: Extremest
- Re: Arraylist.remove problem?? Please help.
- Prev by Date: Re: Strategic Functional Migration and Multiple Inheritance
- Next by Date: Re: adress regex help
- Previous by thread: Re: Arraylist.remove problem?? Please help.
- Next by thread: Re: Arraylist.remove problem?? Please help.
- Index(es):
Relevant Pages
|
Loading