Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Database/World Building

Development::Database/World Building World Building forum, dedicated to the EQEmu MySQL Database. Post partial/complete databases for spawns, items, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old 06-25-2006, 03:58 AM
sesmar
I built it I will Support it!
 
Join Date: Jun 2005
Location: Michigan
Posts: 214
Default MySql Database issues

Does anyone else have trouble running what seems to be simple queries in MySql?

I going through and trying to clean up some stuff in the datbase. Particularly faction tables right now. My Problem is that any of the queries that I want to run to give me the information I need just lock up my server. These queries are really simple and should not have this effect esp when I am able to run what seems to be more complicated queries.

For example:

Code:
SELECT
  npc_faction_id,
  npc_faction.name
FROM
  npc_types
  INNER JOIN spawnentry
    ON npcID=npc_types.id
  INNER JOIN spawn2
    ON spawnentry.spawngroupID=spawn2.spawngroupID
  INNER JOIN  npc_faction
    ON npc_faction.id=npc_types.npc_faction_id
WHERE
  spawn2.zone='qeynos'
GROUP BY
  npc_faction_id,
  npc_faction.name
This query will run with out a problem at all. but if I try and run this:

Code:
SELECT
  npc_faction.id,
  npc_faction.name
FROM
  npc_faction
  LEFT JOIN npc_types
    ON npc_types.npc_faction_id=npc_faction.id
WHERE
  npc_types.id IS NULL
It will lock up my server.

But I can run this query which is the same type of concept:

Code:
SELECT
  id,
  name
FROM
  faction_list
  LEFT JOIN npc_faction_entries
    ON faction_id=id AND npc_faction_id = 2613
WHERE
  npc_faction_id IS NULL
ORDER BY
  name
I have tried doing some searching on the internet but can not find anything as to the cause of this. I have tried this on MySql 4 and 5 and have had problem with other queries as well. Usually they have something to do with LEFT or RIGHT JOINS looking for NULL values. Any information on this would be appreciated
__________________
Reply With Quote
  #2  
Old 06-25-2006, 11:14 AM
GeorgeS
Forum Guide
 
Join Date: Sep 2003
Location: California
Posts: 1,475
Default

ok try

SELECT
npc_faction.id,
npc_faction.name
FROM
npc_faction,npc_types
WHERE (npc_types.npc_faction_id=npc_faction.id)
AND npc_types.id is null


I'm wondering why you would check for 'is null' when the schema dissallows null entries in ncp_types.id

GeorgeS
__________________
Your source for EQ database tools
Toolshop is open for business


http://www.georgestools.chrsschb.com//
Reply With Quote
  #3  
Old 06-25-2006, 11:26 AM
sesmar
I built it I will Support it!
 
Join Date: Jun 2005
Location: Michigan
Posts: 214
Default

The point of the Query is to find all Faction Tables (npc_faction entries) that are not referenced in npc_types.npc_faction_id.

By doing a LEFT JOIN to npc_types I am telling it I want all npc_faction.name and id regardless of whether or not it is in npc_types (hard for me to explain this so I hope you understand what I mean.)

So I am not really checking for NULLs in the npc_types table but rather for rows that a return a NULL in place of a npc_type.id because that means they are not being referenced in the table. It would be that same as this query:

Code:
SELECT
  npc_faction.id,
  npc_faction.name
FROM
  npc_faction
WHERE
  npc_faction.id NOT IN(SELECT npc_types.npc_faction_id FROM npc_types)
This query however also locks up my server and MySql 4 does not support sub queries so even if it did work it would not do me any good in the end.
__________________
Reply With Quote
  #4  
Old 06-25-2006, 02:35 PM
GeorgeS
Forum Guide
 
Join Date: Sep 2003
Location: California
Posts: 1,475
Default

ok figured out the partial problem. I ran the query in my program and the reason I think it locked up is because it used up all memory and took forever to run.

I've got a compiler which creates the standalone .exe from a query, but it does not work as an .exe.

I solved this problem by running the query recursively, but it took me about an hour to run. It did find many 'null's however, which suprised me.

When I get this thing to work, i'll fwd you the solution.
George
__________________
Your source for EQ database tools
Toolshop is open for business


http://www.georgestools.chrsschb.com//

Last edited by GeorgeS; 06-25-2006 at 10:53 PM..
Reply With Quote
  #5  
Old 06-25-2006, 02:50 PM
sesmar
I built it I will Support it!
 
Join Date: Jun 2005
Location: Michigan
Posts: 214
Default

Yeah, I can run the query and it will take about an hour for it to run. I just wanted to know if anyone else was having this issue or if it was just me. I know this is possible to do and I know how to do it programatically I was just hoping that I would not have to do it that way because of the time it will take, it is kind of hard to make it a filter in your DB editor if it takes that long to run. I am just used to working with MS SQL Server and running a query like this never gives me a problem but that is a discussion for a different time and place. Anyways thanks for the feedback and confirmation of my problem.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:58 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3