Showing posts with label trouble. Show all posts
Showing posts with label trouble. Show all posts

Monday, February 13, 2012

a little trouble understanding about primary keys

Hi,

I have a couple of questions regarding primary keys, and whether I really need one or not.

Right now, I am using a GridView control to display all the data in my Access database, but am using a SqlDataSource control to do it. Everything works fine, and I am also using the GridView to Edit/Delete records, and I am using a DetailsView control to insert new records into the database.

The questions I have are these:

1) What I have right now in the database is a value called ID, which is just an autonumber, which has the order of the database, but I would like to change it so that the database sorts by the date awarded, which is a field in the database called "mdate", and make it so that when an admin enters a new date, it sorts automatically by date. Because of that, I am not really sure if I need to have the ID value at all.

I dont understand if it will be of any use, if I want all the values to show up by date, starting from 2006 back. If anyone can explain, or tell me if I am thinking correctly?

2) Also, right now in the database, the clients who started the database inserted the values in the "mdate" field as "Awarded mm/dd/year" instead of just "mm/dd/year".

How could I write a function to go through each record in the "mdate" column, delete the word "Awarded " and then convert it into a datetime object, so I could sort it by date? Is it possible, or would I have to do it manually?

Here is the code I have now:

<%@.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:DetailsViewID="DetailsView1"runat="server"AllowPaging="True"DataSourceID="myDataSource1"

Height="50px"Width="300px"OnPageIndexChanging="DetailsView1_PageIndexChanging"Font-Names="Arial"Font-Size="Smaller">

<Fields>

<asp:CommandFieldShowDeleteButton="True"ShowEditButton="True"ShowInsertButton="True"/>

</Fields>

</asp:DetailsView>

<br/>

</div>

<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="false"Font-Names="Verdana"AutoGenerateEditButton="True"AutoGenerateDeleteButton="true"DataSourceID="myDataSource1"DataKeyNames="ID">

<Columns>

<asp:BoundFieldHeaderText="ID"DataField="ID"ReadOnly="true"Visible="false"/>

<asp:BoundFieldHeaderText="Name"DataField="name"/>

<asp:BoundFieldHeaderText="Department Retired From"DataField="dept"/>

<asp:BoundFieldHeaderText="Current State Of Residence"DataField="state"/>

<asp:BoundFieldHeaderText="Purpose Of Award"DataField="award"/>

<asp:BoundFieldHeaderText="Date Awarded"DataField="mdate"/>

</Columns>

<RowStyleFont-Size="Smaller"Height="50px"HorizontalAlign="Center"/>

</asp:GridView>

<asp:SqlDataSourceID="myDataSource1"runat="server"SelectCommand="SELECT * from [finawards]"ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|finawards_new.mdb"ProviderName="System.Data.OleDb"UpdateCommand="UPDATE [finawards] SET [name] = @.name, [dept] = @.dept, [state] = @.state, [award] = @.award, [mdate] = @.mdate WHERE [ID] = @.ID"DeleteCommand="DELETE FROM finawards WHERE [ID] = @.ID"InsertCommand="INSERT INTO finawards (name, dept, state, award, mdate) VALUES (@.name, @.dept, @.state, @.award, @.mdate)"></asp:SqlDataSource>

</form>

</body>

</html>

Thanks,

sls29 wrote:

1) What I have right now in the database is a value called ID, which is just an autonumber, which has the order of the database, but I would like to change it so that the database sorts by the date awarded, which is a field in the database called "mdate", and make it so that when an admin enters a new date, it sorts automatically by date. Because of that, I am not really sure if I need to have the ID value at all.

Modify your SELECT statement to add an ORDER BY with ASC or DESC clause at the end.

SelectCommand="SELECT * from [finawards] ORDER BY mdate"

Yes. It is a good idea to have a Primary Key. You may not be using it now but every table must have a PK.

sls29 wrote:

How could I write a function to go through each record in the "mdate" column, delete the word "Awarded " and then convert it into a datetime object, so I could sort it by date? Is it possible, or would I have to do it manually?

You could use a REPLACE function to remove all the "Awarded" values. something like this:

SELECT REPLACE(Field1, "Awarded", "") FROM Table1;

After you do that you can manually change the datatype of the column

|||

Close, you want:

UPDATE Table1 SET Field1=REPLACE(Field1,"Awarded ","")

that'll get rid of the pesky text.

Yes, every table should have a primary key. If you want to pull back by mdate, fine, put an index on it too. But without a primary key column like the id field, what if two awards are given out to the same person/people/thing on the same day? How would/could you distinguish between the records if all the columns are exactly the same? That's what the ID field is doing for you. In addition, if you have records that refer back to the award (by ID), then if at a later time you decide to change the mdate or some other field in the table, then your other tables will still be able to find the corresponding record because the ID never changes (for that record).

|||

Thank you for the help.

So, basically, I can sort the GridView display anyway I want, but will still need the ID value there, just for unique identification purposes? I do not have to have the ID effect the ordering of how the GridView will display...

About how to get rid of the "Awarded" text. So, basically, I should be able to run a command:

UPDATE finawards SET mdate=REPLACE(mdate, "Awarded ", "");

Right in Access, and then change the column type to a date/time object?

Thanks again, I really appreciate it. I am trying to learn and get practice with ASP.NET 2.0, and it is nice to have a place to ask questions, and get some advice!

|||

1). Personally,I try my best not to use date as primary key as it can be duplicated. If the reason just want to get the data sorted in the database, I believe you can always sort the data in your query. So, I'd use the ID for PK.

2). Try this

// this will set the mdate to the 10 characters of the mdate from the right, I assume the last 10 characters in the mdate field is all date format.

Update [Table_Name] Set mdate = Right(mdate,10);

run the query, and change the column type to datetime manually in the design view.

good luck

|||

Thanks again for all the help. I changed all the values of my "mdate" field to take away the "Awarded " test, and then converted that field to be of type "datetime" and changed the format string to "Short Date" so it would only show the date in the form mm/dd/year.

But, for some reason, when it displays the mdate field in the GridView it shows up as "mm/dd/year 12:00am".

Is there a reason it is showing a time as well, even though there is no time in the database? Is there something I have to add to my code so that it only shows up in short date form?

Right now, I have the same code except for theORDER BY mdate addition to my SelectCommand.

I was not sure where to add the formatting restrictions. When I try to insert data also, it also gives me a type mismatch error. I am assuming that is because I put in only a date, and not a time?

Thanks in advance for any advice.

|||

I was able to get only the date to display in the GridView by adding this to my boundfield for the mdate field.

DataFormatString = "{0:mm/dd/yyyy}" HtmlEncode="False"3

The problem I am having now is that when I try to insert a new record, I get a "Data type mismatch criteria" error.

I was reading that the problem is because even if it is in the right format, Access will not allow a DateTime object to be inserted as a string. How can I convert the value that is entered into the "mdate" textbox created by the DetailsView control to a ShortDate object so that I can insert it into the database?

Thanks again.

|||

I tried a couple of new things to fix my problem, but with no luck.

First, I tried adding the InsertParameters collection to my SqlDataSource and set the Type of my "mdate" as DateTime, but that did not work.

<InsertParameters>
<asp:Parameter Name="ID" Type="String" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="dept" Type="String" />
<asp:Parameter Name="state" Type="String" />
<asp:Parameter Name="award" Type="String" />
<asp:Parameter Name="mdate" Type="DateTime" />
</InsertParameters>

Then, I tried to modify the ItemInserting function of the DetailsView so that it checks for which value is the "mdate" function, and converts it to a DateTime object, but I am still getting the same error.

protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
for (int i = 0; i < e.Values.Count; i++)
{
if (e.Values[i].ToString().Contains("/"))
{
Convert.ToDateTime(e.Values[i].ToString());
}
else
{
e.Values[i] = Server.HtmlEncode(e.Values[i].ToString());
}
}
}

I know the function is a little primitive, but I just figured that if the current value contains a "/", it would have to be the mdate field, since there is no other field that would have that in it.

Is there anything fundamentally wrong? I am totally confused...

|||

Try playing around in the SqlDataSource_Inserting event. There is a lot more control there with what actually gets sent to the database.

Just curious, shouldn't you be using the AccessDataSource control with Access?

|||

Thanks for the tip, I will look at that event also. The reason I am using the SqlDataSource control is because in the quickstarts it had mentioned that you can use the SqlDataSource control with an Access database also, and it would give you the "added functionality" that comes with the SqlDataSource control.

Maybe I can try to change it, and see if that works better.

|||

Well, I tried to change my SqlDataSource_Inserting function to the following:

Convert.ToDateTime(myDataSource1.InsertParameters["mdate"].ToString().Trim());

That did not work, but atleast now I get a different errorSmile [:)]

Now, when I try to insert a new record, I get the error:

"The string was not recognized as a valid DateTime. There is an unknown word at index 0".

Is the above code that I wrote enough for the Inserting function? I thought since the only problem I was having was with mdate, it would convert that value to a DateTime object, and then perform the insert command, but now I am getting this new error...Confused [*-)]

I tried adding the Trim() to my Convert statement thinking that was why I was getting my error, but I am still getting it.

Any ideas? Thanks again...

|||

I finally got this resolved! I ended up getting rid of the DetailsView control altogether, and just included a regular form to insert into the database. Then I used an OleDbCommand and a ExecuteNonQuery method to insert the values.

I was able to insert the date properly also using DateTime.Parse(), and everything is working great now.

Thanks to everyone for their help.

Saturday, February 11, 2012

A little connection chaos.

Hi Mike,

Me again, in trouble as usual.

Finally got my application finished, and want to have the database on a server, with the ability to access it from the Internet, or from our internal domain. Had some help setting up the server wirth Small Business Server 2003, after which everything went pear shaped. My helper renamed my PC, on which I'd been using SqlExpress as a local server. With that, in Visual Studio I was only able to access my database by changing the connection string to a User Instance.

I now have SqlExpress installed on the SBS Server 2003, and installed a copy of my database there. I have a situation that logged on as a User on my PC, I cannot connect to my database which is on the server, either in Management Studio, or in Visual Studio. I can 'see' the server instance, but cannot connect. I think it's something to do with permissions, but dont know how to fix this. I've had two MS Sql error messages one No. 4060 and the other No 916.

If I log on as administrator, things change. I can connect to the server database in Management Studio, and open all my tables, however, if I try to do the same in Visual Studio, this fails. Initially I couldnt even connect to a User Instance, but on the last try I was able to. I've read your FAQs and Blogs, but haven't progressed much.

My big problem is in wanting to deploy my application, I need to establish the correct connection strings for my settings. Since I have to manually change all my Crystal Reports connection strings as well, I'd prefer to only have to do this once.

I know this isn't much concrete info on which to work, but hopefully it will give us a start.

As User logon the two sqlservr.exe Processes you mention where running. As an administrator logon, there are two sqlservr.exe processes running, one as NETWORK SERVICE the other as SYSTEM. if that is any help.

John

hi John

Tailor wrote:

..

I now have SqlExpress installed on the SBS Server 2003, and installed a copy of my database there. I have a situation that logged on as a User on my PC, I cannot connect to my database which is on the server, either in Management Studio, or in Visual Studio. I can 'see' the server instance, but cannot connect. I think it's something to do with permissions, but dont know how to fix this. I've had two MS Sql error messages one No. 4060 and the other No 916.

If I log on as administrator, things change. I can connect to the server database in Management Studio, and open all my tables, however, if I try to do the same in Visual Studio, this fails. Initially I couldnt even connect to a User Instance, but on the last try I was able to. I've read your FAQs and Blogs, but haven't progressed much.

...

please verify an actual Login (individual or at group granularity) exists on the SBS installed instance for your remote credentials...

that's meaning, your limited user has probably not been granted authentication rights to the instance..

regards

|||

Hi Andrea,

My apologies for the delay in replying, as I've been away for about a week.

I'm sure you are correct, so will see if I can sort it out, although it's my first experience of SBS.

Thanks

John

Thursday, February 9, 2012

A Game Company in Trouble

My Name is Nick Soutter, I am the owner of a small game company, Aepox Games
(We're in the middle of a name change from "Lamar Games"),
www.lamargames.net.

Our first commercial game, Andromeda Online (www.andromedaonline.net) is
going into beta soon. It runs on an evaluation edition of SQL Server 2000
(our intention is, when it launches, we earn the money to buy a copy before
the evaluation expires).

We have been testing Andromeda Online, and found that saves to the database
take about 10 seconds (we were anticipating less than 1). We felt we need
somebody experienced in optimizing sql databases to help us optimize the
database, and get it running in the best method for our particular
application.

Our program accesses the database in Java, and people with understanding in
how to optimize java connections would be a tremendous help.

My company is small, and we honestly cant afford much. Everybody on this
project, from the sound guys to the graphic artist, has worked for 1/10 to
1/100 of the value of the job. We're simply a starting company looking for
dedicated people who are willing to work more for credit than money.

We can offer credit on our website
(http://www.andromedaonline.net/credits.html) to anybody who helps us, but
little more (maybe $100, but we're very over budget, and in desperate need
of help). Because of how we intend the game to run (with maybe 100-200
concurrent games running online), a 10 second save time is simply
unacceptable.

Anybody who would be willing to help us, please send a resume to
help@.andromedaonline.net. Experience would be nice, but not a requirement.
We're looking for someone who can talk with our programmer about the types
of calls made to our SQL database, and then can log into the DB and optimize
it to run as fast as possible considering our specific needs.

Thank you for your time.

Nick Soutter

Aepox (Lamar) GamesBlackHawke wrote:
> We have been testing Andromeda Online, and found that saves to the database
> take about 10 seconds (we were anticipating less than 1). We felt we need
> somebody experienced in optimizing sql databases to help us optimize the
> database, and get it running in the best method for our particular
> application.
>
> Our program accesses the database in Java, and people with understanding in
> how to optimize java connections would be a tremendous help.

Some simple advice, without knowing anything about your application.
It's highly unlikely that the problem is related to your use of Java-
based interfaces to the database. The problem is almost certainly with
the SQL that you are running, and is independent of the means of issuing
that SQL to the database itself. An exception applies, though, if
you're using some high-level abstraction like an OR mapper that
generates the SQL for you. Is this hand-written JDBC and SQL, or
something more complex?

> Anybody who would be willing to help us, please send a resume to
> help@.andromedaonline.net. Experience would be nice, but not a requirement.
> We're looking for someone who can talk with our programmer about the types
> of calls made to our SQL database, and then can log into the DB and optimize
> it to run as fast as possible considering our specific needs.

Given your financial constraints, it would perhaps be more prudent for
you to take advantage of the advice freely offered on this newsgroup.
You'd be expected to take part in finding the solution, by for example
putting together test cases and doing some troubleshooting, but if you
have a real question about a factual or difficult issue, someone will
almost certainly jump in to help.

A good place to start is to look over the statements that are issued in
a save. Many databases have a logging mode that can capture this info,
but if your database doesn't have such a mode or flag, you could do it
from the application or with a filter JDBC driver. So to start with the
easiest solution, which database are you using?

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation|||BlackHawke (blackhawke@.legacygames.net) writes:
> Our first commercial game, Andromeda Online (www.andromedaonline.net) is
> going into beta soon. It runs on an evaluation edition of SQL Server
> 2000 (our intention is, when it launches, we earn the money to buy a
> copy before the evaluation expires).

When did you download this evaluation edition? Beware that the original
evaluation edition is vulnerable for the Slammer worm. If you go to
http://www.microsoft.com/sql you can obtain a version of the Evaluation
Edition that is Slammer-safe.

> We have been testing Andromeda Online, and found that saves to the
> database take about 10 seconds (we were anticipating less than 1). We
> felt we need somebody experienced in optimizing sql databases to help us
> optimize the database, and get it running in the best method for our
> particular application.

What exactly are you saving? Does it take 10 seconds to save a single
row to the database? Or does it take 10 seconds to save a player's
entire game?

The latter could mean a whole lot calls to SQL Server to insert data.
If all operations are through INSERT statements sent from the Java
code, there is a whole lot to win by using stored procedures. For even
higher speed, you could construct an XML document, and then unpack that on
the SQL Server side with OPENXML(). You save a lot of network roundtrips
that way.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||To add to everybody else's statements.

Run Profiler against the DB and see exactly what is being sent. If you can
get statements out then you can look at the execution plans and perhaps that
will point out a reason for the preceived slowness.

--

---------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

"Erland Sommarskog" <sommar@.algonet.se> wrote in message
news:Xns93BC69EEEF67FYazorman@.127.0.0.1...
> BlackHawke (blackhawke@.legacygames.net) writes:
> > Our first commercial game, Andromeda Online (www.andromedaonline.net) is
> > going into beta soon. It runs on an evaluation edition of SQL Server
> > 2000 (our intention is, when it launches, we earn the money to buy a
> > copy before the evaluation expires).
> When did you download this evaluation edition? Beware that the original
> evaluation edition is vulnerable for the Slammer worm. If you go to
> http://www.microsoft.com/sql you can obtain a version of the Evaluation
> Edition that is Slammer-safe.
> > We have been testing Andromeda Online, and found that saves to the
> > database take about 10 seconds (we were anticipating less than 1). We
> > felt we need somebody experienced in optimizing sql databases to help us
> > optimize the database, and get it running in the best method for our
> > particular application.
> What exactly are you saving? Does it take 10 seconds to save a single
> row to the database? Or does it take 10 seconds to save a player's
> entire game?
> The latter could mean a whole lot calls to SQL Server to insert data.
> If all operations are through INSERT statements sent from the Java
> code, there is a whole lot to win by using stored procedures. For even
> higher speed, you could construct an XML document, and then unpack that on
> the SQL Server side with OPENXML(). You save a lot of network roundtrips
> that way.
>
> --
> Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||BlackHawke wrote:
> I suspect that most of the problem lies in how our database is configured.
> Knowing nothing about configuring these things, I set it up in the default
> settings. I've boosted the priority, and that helped, but I know nothing
> about enhancing the database response time.
> We are using MS SQL Server 2000... Is that what you meant by what database
> are we using? As far as how the JAVA code interacts with it, I'd have to ask
> the programmer.

Okay, please do ask the programmer to make an appearance here; there's
no reason to work through a level of indirection.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation|||What database are you using Oracle/MSSQL/MySQL/Postgresql and the platform
NT/XP/Linux/BSD? Without knowing that there is no way to make any
recommendations regarding performance tunning.

"Christopher Browne" <cbbrowne@.acm.org> wrote in message
news:bf8u43$c4538$1@.ID-125932.news.uni-berlin.de...
> "BlackHawke" <blackhawke@.legacygames.net> writes:
> > My Name is Nick Soutter, I am the owner of a small game company, Aepox
Games
> > Our program accesses the database in Java, and people with understanding
in
> > how to optimize java connections would be a tremendous help.
> A few database performance principles are vital:
> 1. It's probably fruitful to find someone that knows something about
> SQL Server. There are likely some parameters that may be tuned that
> will improve performance a fair bit just by having someone turn a few
> "virtual knobs."
> 2. There is a pretty high startup cost when opening a connection or
> when first submitting a query.
> If the connection or prepared query can get reused over and over, that
> amortizes the startup cost.
> For instance, if they keep opening and closing the connection over and
> over again, that would be an excellent reason to expect performance to
> be terrible.
> When querying data, the usual rule is that while running one query to
> pull 100,000 rows of data is expensive, but not _too_ expensive; the
> flip case, of submitting 100,000 queries, each drawing 1 row, is a
> RIDICULOUS way of doing things, and will perform terribly. I'm not
> sure if Sybase designed "mass data load" facilities into their
> database (which later was bought by Microsoft), but it would be a
> little surprising if there wasn't.
> 3. Indexes can be really helpful.
> Certainly for improving query performance, but sometimes even on
> inserts, in terms of validating things.
> For instance, if the DB schema does integrity checks on foreign keys,
> you probably need to have indexes on those foreign tables in order for
> it not to behave like shaking up a bag of rocks.
> --
> wm(X,Y):-write(X),write('@.'),write(Y). wm('cbbrowne','ntlug.org').
> http://cbbrowne.com/info/lsf.html
> "How much more helpful could I be than to provide you with the
> appropriate e-mail address? I could engrave it on a clue-by-four and
> deliver it to you in Chicago, I suppose." -- Seen on Slashdot...|||If I failed to mention it earlier, SQL 2000, Evaluation Edition, on Windows
2003 Server, Eval Edition.

I'll ask the programmer to make an appearance ASAP.

Nick
"Ed Yu" <ekyu@.sc.rr.com> wrote in message
news:H1_Ra.247931$nr.9986970@.twister.southeast.rr. com...
> What database are you using Oracle/MSSQL/MySQL/Postgresql and the platform
> NT/XP/Linux/BSD? Without knowing that there is no way to make any
> recommendations regarding performance tunning.
> "Christopher Browne" <cbbrowne@.acm.org> wrote in message
> news:bf8u43$c4538$1@.ID-125932.news.uni-berlin.de...
> > "BlackHawke" <blackhawke@.legacygames.net> writes:
> > > My Name is Nick Soutter, I am the owner of a small game company, Aepox
> Games
> > > Our program accesses the database in Java, and people with
understanding
> in
> > > how to optimize java connections would be a tremendous help.
> > A few database performance principles are vital:
> > 1. It's probably fruitful to find someone that knows something about
> > SQL Server. There are likely some parameters that may be tuned that
> > will improve performance a fair bit just by having someone turn a few
> > "virtual knobs."
> > 2. There is a pretty high startup cost when opening a connection or
> > when first submitting a query.
> > If the connection or prepared query can get reused over and over, that
> > amortizes the startup cost.
> > For instance, if they keep opening and closing the connection over and
> > over again, that would be an excellent reason to expect performance to
> > be terrible.
> > When querying data, the usual rule is that while running one query to
> > pull 100,000 rows of data is expensive, but not _too_ expensive; the
> > flip case, of submitting 100,000 queries, each drawing 1 row, is a
> > RIDICULOUS way of doing things, and will perform terribly. I'm not
> > sure if Sybase designed "mass data load" facilities into their
> > database (which later was bought by Microsoft), but it would be a
> > little surprising if there wasn't.
> > 3. Indexes can be really helpful.
> > Certainly for improving query performance, but sometimes even on
> > inserts, in terms of validating things.
> > For instance, if the DB schema does integrity checks on foreign keys,
> > you probably need to have indexes on those foreign tables in order for
> > it not to behave like shaking up a bag of rocks.
> > --
> > wm(X,Y):-write(X),write('@.'),write(Y). wm('cbbrowne','ntlug.org').
> > http://cbbrowne.com/info/lsf.html
> > "How much more helpful could I be than to provide you with the
> > appropriate e-mail address? I could engrave it on a clue-by-four and
> > deliver it to you in Chicago, I suppose." -- Seen on Slashdot...|||While you may suggest the obvious such as indexing the proper columns, you
need to know much more about the system as a whole to even begin suggesting
scenerio that could be the bottleneck. In fact, even if you have follow all
the best RDBMS best practice (including tunning SQL by generating execution
plans), you may have chocked up your system if you are not careful about
creating large objects on the java end or misconfigurating the connection
pool. So, with that said, we really need to begin at point zero, which in
this case is:

1) Platform - Win2K
2) Database - MSSQL 2000 Eval
3) Java - ? a web application I assume, it is JSP? Servlet? Using any type
of framework Struts/WebWorks?
4) Web server - ? Apache/IIS/Tomcat?
5) Application Server - ? Tomcat/Weblogic/Websphere?
6) Physical system configuration - machine A (web server), machine B
(application server), machine C (database server)
7) Client - ? Http client/Applet/C/C++ clients?
8) Protocol - ? HTTP/HTTPS/Socket?

"Christopher Browne" <cbbrowne@.acm.org> wrote in message
news:bfa1fs$ci27r$1@.ID-125932.news.uni-berlin.de...
> "Ed Yu" <ekyu@.sc.rr.com> writes:
> > What database are you using Oracle/MSSQL/MySQL/Postgresql and the
platform
> > NT/XP/Linux/BSD? Without knowing that there is no way to make any
> > recommendations regarding performance tunning.
> You're very much missing the point.
> The three principles I presented are true regardless of platform and
> regardless of DBMS implementation. While different implementations
> may differ, there ARE some near universal principles.
> --
> (format nil "~S@.~S" "cbbrowne" "acm.org")
> http://www3.sympatico.ca/cbbrowne/rdbms.html
> "C++ is more of a rube-goldberg type thing full of high-voltages,
> large chain-driven gears, sharp edges, exploding widgets, and spots to
> get your fingers crushed. And because of it's complexity many (if not
> most) of it's users don't know how it works, and can't tell ahead of
> time what's going to cause them to loose an arm." -- Grant Edwards|||> 1) Platform - Win2K
> 2) Database - MSSQL 2000 Eval
> 3) Java - ? a web application I assume, it is JSP? Servlet? Using any type
> of framework Struts/WebWorks?
> 4) Web server - ? Apache/IIS/Tomcat?
> 5) Application Server - ? Tomcat/Weblogic/Websphere?
> 6) Physical system configuration - machine A (web server), machine B
> (application server), machine C (database server)
> 7) Client - ? Http client/Applet/C/C++ clients?
> 8) Protocol - ? HTTP/HTTPS/Socket?

Hello Everyone, I'm the lead programmer on this project. Thanks ahead
of time for any-and-all good advice coming from you fine folks :)
Well, this is a standard java application, no web-server involved. Im
using microsofts JDBC4 SQLServer driver for my connection to the
database, no ODBC (ugh!) involved. Also, Im using the apache commons
connection pool classes to handle all of the database connection
pooling as well as the player execution thread pooling.

I dont think we have any indexes setup on our tables just yet. Most of
the tables have the primary key set to an identity column I call
"IndexCol". The important tables have this ID column as well as a
"GameID", "PlayerID", "ShipID" fields to determin exactly which object
this row of data corresponds to. Do I want to setup the indexs on
these three columns?

The speed problems we see currently, arent on the SELECT end of the
spectrum, they are on the INSERT parts. I am using prepared statements
to "INSERT" the data row-by-row into the database. Im not using batch
mode at the moment. I've tried to make the tables as lean as possible,
factoring out columns into other tables where possible. The main ship
table is pretty large, maybe 100 columns of int/smallint/bit data, no
text. Right now, to update the game specifics, I delete all the data
in that table for the specific game, then I use the prepared
statements to re-insert the updated data. I dont want to use "UPDATE"
sql because some records aren't restored, thats why I like the
delete/insert combo.

If theres any other info I can send, please let me know.

Thanks, Greg.|||[Followups trimmed to comp.databases.ms-sqlserver, as this is the only
relevant group.]

DiscoStu (gregfrommer@.hotmail.com) writes:
> The speed problems we see currently, arent on the SELECT end of the
> spectrum, they are on the INSERT parts. I am using prepared statements
> to "INSERT" the data row-by-row into the database. Im not using batch
> mode at the moment. I've tried to make the tables as lean as possible,
> factoring out columns into other tables where possible. The main ship
> table is pretty large, maybe 100 columns of int/smallint/bit data, no
> text. Right now, to update the game specifics, I delete all the data
> in that table for the specific game, then I use the prepared
> statements to re-insert the updated data. I dont want to use "UPDATE"
> sql because some records aren't restored, thats why I like the
> delete/insert combo.

So, how many rows do insert when it takes 10 seconds to save a game?

The obvious improvement I see is to use stored procedures instead. If
that doesn't help, package data in an XML document and send this to
SQL Server, and then write a stored procedure that unpacks it with
OPENXML. Or use bulk-copy routines to load the data, but I have no
idea to do that from JDBC.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Without considering the physical server hardware and network configurations,
looks like you need a cluster index (not primary key) on the GAMEID column.
Since you do not have any index on this column, everytime someone starts the
same, you are doing a full table scan to locate and remove rows associated
with the GAMEID.

Looks like you need to read a little more about RDBMS application
programming and best pratices. BTW, I think for MSSQL, at least you need to
place the data files and log files on to seperate hardware (ie. disks
preferably on different controllers).

In addition, I am a little uneasy about using RDBMS for games since SQL
engines, IMHO, got too much overhead for a gaming application.

"DiscoStu" <gregfrommer@.hotmail.com> wrote in message
news:8457f9da.0307191352.2dbcbf2e@.posting.google.c om...
> > 1) Platform - Win2K
> > 2) Database - MSSQL 2000 Eval
> > 3) Java - ? a web application I assume, it is JSP? Servlet? Using any
type
> > of framework Struts/WebWorks?
> > 4) Web server - ? Apache/IIS/Tomcat?
> > 5) Application Server - ? Tomcat/Weblogic/Websphere?
> > 6) Physical system configuration - machine A (web server), machine B
> > (application server), machine C (database server)
> > 7) Client - ? Http client/Applet/C/C++ clients?
> > 8) Protocol - ? HTTP/HTTPS/Socket?
> Hello Everyone, I'm the lead programmer on this project. Thanks ahead
> of time for any-and-all good advice coming from you fine folks :)
> Well, this is a standard java application, no web-server involved. Im
> using microsofts JDBC4 SQLServer driver for my connection to the
> database, no ODBC (ugh!) involved. Also, Im using the apache commons
> connection pool classes to handle all of the database connection
> pooling as well as the player execution thread pooling.
>
> I dont think we have any indexes setup on our tables just yet. Most of
> the tables have the primary key set to an identity column I call
> "IndexCol". The important tables have this ID column as well as a
> "GameID", "PlayerID", "ShipID" fields to determin exactly which object
> this row of data corresponds to. Do I want to setup the indexs on
> these three columns?
> The speed problems we see currently, arent on the SELECT end of the
> spectrum, they are on the INSERT parts. I am using prepared statements
> to "INSERT" the data row-by-row into the database. Im not using batch
> mode at the moment. I've tried to make the tables as lean as possible,
> factoring out columns into other tables where possible. The main ship
> table is pretty large, maybe 100 columns of int/smallint/bit data, no
> text. Right now, to update the game specifics, I delete all the data
> in that table for the specific game, then I use the prepared
> statements to re-insert the updated data. I dont want to use "UPDATE"
> sql because some records aren't restored, thats why I like the
> delete/insert combo.
> If theres any other info I can send, please let me know.
> Thanks, Greg.|||Ed Yu (ekyu@.sc.rr.com) writes:
> Without considering the physical server hardware and network
> configurations, looks like you need a cluster index (not primary key) on
> the GAMEID column. Since you do not have any index on this column,
> everytime someone starts the same, you are doing a full table scan to
> locate and remove rows associated with the GAMEID.

Since the access problems were with saving, indexes are not so much of
an issue, although we don't know what the statements look like. INSERT
VALUES does not need any indexes, unless there is some trigger involved.
True, though, DiscoStu is deleting all data for a game first, and that
DELETE could use an index. I would suspect, however, that at this point
he don't have that much data in the database yet, so he has not yet
arrived at problems where indexes are the solution.

> Looks like you need to read a little more about RDBMS application
> programming and best pratices. BTW, I think for MSSQL, at least you need
> to place the data files and log files on to seperate hardware (ie. disks
> preferably on different controllers).

Undoubtedly this can be good for performance, but there are many systems
out there that don't have this configuration and still have good
performance. I don't think this is the right place to start.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Hal Berenson (haroldb@.truemountainconsulting.com) writes:
> Ok, let's start with something very basic. Are you wrapping the delete
> and inserts in a transaction, or is each statement a separate
> transaction? At a minimum all of the inserts should be inside a
> user-defined transaction.

Not talking of the fact that the DELETE where he sweeps the old data
should be part of that transaction too. Not so much for the speed of
the save, but for the integrity. If there is a crash before everything
is saved, the player should at least get his old save back. Not an
incomplete save from which he cannot continue, and neither nothing at
all.

> As for your general problem of lack of database expertise, I doubt that
> "credit" is going to get you all the help you need. You may have to look
> for a consultant who will trade time for a small amount of equity in your
> company.

Yes, the gaming company appears to be in dear need of venture capital
one way or another.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||"BlackHawke" <blackhawke@.legacygames.net> writes:

> My Name is Nick Soutter, I am the owner of a small game company, Aepox Games
> (We're in the middle of a name change from "Lamar Games"),
> www.lamargames.net.
>
> Our first commercial game, Andromeda Online (www.andromedaonline.net) is
> going into beta soon. It runs on an evaluation edition of SQL Server 2000
> (our intention is, when it launches, we earn the money to buy a copy before
> the evaluation expires).
>
> We have been testing Andromeda Online, and found that saves to the database
> take about 10 seconds (we were anticipating less than 1). We felt we need
> somebody experienced in optimizing sql databases to help us optimize the
> database, and get it running in the best method for our particular
> application.

You need to find out what it is doing during these 10 seconds. Run
some kind of profiling on your progarm to see what it is doing. i.e
Opening JDBC connection (if it's doing that), getting a connection
from a connection pool (you really should be doing something like
that), sending sql statement to server, waiting for server to complete
the statement,closing (or releasing) the dabase connection. When you've found
out how much time these various things are taking then you can see which parts
you need to optimise.

> Our program accesses the database in Java, and people with understanding in
> how to optimize java connections would be a tremendous help.

Use pooling so that you don't have to open a connection every time you
want to access the database

If your problem is tha database then you'll more than likely get
improvements by looking at ths SQL you are using and seing if you can
rephrase your statement in a btter way (i.e. have a look at any joins
you are using and whic table is the driving table in a join, make sure
that any table lookups are using indexes etc. ) You'll fidn that any
optimistaion you make in this area will make much more of a difference
than any tweaking of database parameters that you can do.

>
> My company is small, and we honestly cant afford much. Everybody on this
> project, from the sound guys to the graphic artist, has worked for 1/10 to
> 1/100 of the value of the job. We're simply a starting company looking for
> dedicated people who are willing to work more for credit than money.

Good luck with your product, I hope it works out so that all the guys
who've been working for little money can start getting very lareg
pay-checks

> We can offer credit on our website
> (http://www.andromedaonline.net/credits.html) to anybody who helps us, but
> little more (maybe $100, but we're very over budget, and in desperate need
> of help). Because of how we intend the game to run (with maybe 100-200
> concurrent games running online), a 10 second save time is simply
> unacceptable.

You can have this info for nothing, enjoy :-).

Here's some more advice for free. If you've got nobody on your team
who knows about databases and their design your design is probably a
bit if a mess. It will then probably take a bit more than some tunig
to sort out your problems. Just have a look at posts in some of the
Oracle newsgroups to get some idea of what professional database
people think about letting java programmers loose on databases :-)

> Anybody who would be willing to help us, please send a resume to
> help@.andromedaonline.net. Experience would be nice, but not a requirement.
> We're looking for someone who can talk with our programmer about the types
> of calls made to our SQL database, and then can log into the DB and optimize
> it to run as fast as possible considering our specific needs.

As someone else posted , get one of the programmers to come on here, but
get him/her to read the above first and come ready with answers to the
questions above and then getting answers back will be a lot quicker,

cheers

Phil

--

As of now they're on Double SECRET Probation!|||Phil Britton <phil@.phil-britton.com> wrote in message news:<ulluryleo.fsf@.phil-britton.com>...
> "BlackHawke" <blackhawke@.legacygames.net> writes:
> > My Name is Nick Soutter, I am the owner of a small game company, Aepox Games
> > (We're in the middle of a name change from "Lamar Games"),
> > www.lamargames.net.
> > Our first commercial game, Andromeda Online (www.andromedaonline.net) is
> > going into beta soon. It runs on an evaluation edition of SQL Server 2000
> > (our intention is, when it launches, we earn the money to buy a copy before
> > the evaluation expires).
> > We have been testing Andromeda Online, and found that saves to the database
> > take about 10 seconds (we were anticipating less than 1). We felt we need
> > somebody experienced in optimizing sql databases to help us optimize the
> > database, and get it running in the best method for our particular
> > application.
> You need to find out what it is doing during these 10 seconds. Run
> some kind of profiling on your progarm to see what it is doing. i.e
> Opening JDBC connection (if it's doing that), getting a connection
> from a connection pool (you really should be doing something like
> that), sending sql statement to server, waiting for server to complete
> the statement,closing (or releasing) the dabase connection. When you've found
> out how much time these various things are taking then you can see which parts
> you need to optimise.
> > Our program accesses the database in Java, and people with understanding in
> > how to optimize java connections would be a tremendous help.
> Use pooling so that you don't have to open a connection every time you
> want to access the database
> If your problem is tha database then you'll more than likely get
> improvements by looking at ths SQL you are using and seing if you can
> rephrase your statement in a btter way (i.e. have a look at any joins
> you are using and whic table is the driving table in a join, make sure
> that any table lookups are using indexes etc. ) You'll fidn that any
> optimistaion you make in this area will make much more of a difference
> than any tweaking of database parameters that you can do.
> > My company is small, and we honestly cant afford much. Everybody on this
> > project, from the sound guys to the graphic artist, has worked for 1/10 to
> > 1/100 of the value of the job. We're simply a starting company looking for
> > dedicated people who are willing to work more for credit than money.
> Good luck with your product, I hope it works out so that all the guys
> who've been working for little money can start getting very lareg
> pay-checks
>
> > We can offer credit on our website
> > (http://www.andromedaonline.net/credits.html) to anybody who helps us, but
> > little more (maybe $100, but we're very over budget, and in desperate need
> > of help). Because of how we intend the game to run (with maybe 100-200
> > concurrent games running online), a 10 second save time is simply
> > unacceptable.
> You can have this info for nothing, enjoy :-).
> Here's some more advice for free. If you've got nobody on your team
> who knows about databases and their design your design is probably a
> bit if a mess. It will then probably take a bit more than some tunig
> to sort out your problems. Just have a look at posts in some of the
> Oracle newsgroups to get some idea of what professional database
> people think about letting java programmers loose on databases :-)
>
> > Anybody who would be willing to help us, please send a resume to
> > help@.andromedaonline.net. Experience would be nice, but not a requirement.
> > We're looking for someone who can talk with our programmer about the types
> > of calls made to our SQL database, and then can log into the DB and optimize
> > it to run as fast as possible considering our specific needs.
> As someone else posted , get one of the programmers to come on here, but
> get him/her to read the above first and come ready with answers to the
> questions above and then getting answers back will be a lot quicker,
> cheers
> Phil

Hi

Have noted what you guys are trying to do, and as a DBA and
ex-developer, thought I'd try and help point you in the right
direction. From the sounds of what you are doing and your tight
budget, I guess you're not running the SQL DB on a powerful,
multi-processor, multi-GB RAM, multi-SCSI Array system. If this is
the case and you're system is modest, then there isn't a great deal
you can do for tuning the SQL Server itself.

As someone mentioned earlier, you're more likely to get better
performance by looking at the way you do your SQL coding - think there
is a quote in the O'Reilly T-SQL Programming book, that says
"...optimising SQL Server settings only accounts for around 20% of
performance improvement, 80% is obtained by tuning your SQL code...".
Do you make use of Stored Procedures? This will help, as compared to
using SQL code from the Client. Don't use SQL Server Cursors - make
sure your code is Set-based (what RDBMS's are designed to run best
with). Look into the Metadata structure - are there loads of joins?
If so, consider denormalising and test to see if this gives an
improvement. Is it the SQL Server that is slow to update? or is it
the connection/network link? You might find that the actual writing
to the DB is quick and the bottleneck is elsewhere.

HTH

n0t999