Book a Demo

Author Topic: Why does this SQL statement blocks my EA?  (Read 4227 times)

siaccarino

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-1
    • View Profile
Why does this SQL statement blocks my EA?
« on: January 23, 2019, 11:24:31 pm »
Intention: Get all objects with a tag XYZ or that are connected to objects with a tag XYZ

SELECT DISTINCT t_object.Object_ID
FROM t_objectproperties,t_object,t_connector
WHERE
   t_objectproperties.Property = "MustHaveThisTag"
AND
   ((t_connector.Start_Object_ID = t_objectproperties.Object_ID AND t_object.Object_ID = t_connector.Start_Object_ID)
OR
   (t_connector.End_Object_ID = t_objectproperties.Object_ID AND t_object.Object_ID = t_connector.End_Object_ID))

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Why does this SQL statement blocks my EA?
« Reply #1 on: January 23, 2019, 11:42:09 pm »
Because of they way you are writing the query.

Write you query using the join syntax and you'll get a whole lot further.
This query selects all objects that have the tagged value, and a connector.

Code: [Select]
SELECT DISTINCT o.Object_ID
FROM ((t_objectproperties tv
inner join t_object o on o.Object_ID = tv.Object_ID)
inner join t_connector c on (o.Object_ID = c.Start_Object_ID or o.Object_ID = c.End_Object_ID))
WHERE
tv.Property = 'MustHaveThisTag'

Geert

siaccarino

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-1
    • View Profile
Re: Why does this SQL statement blocks my EA?
« Reply #2 on: January 23, 2019, 11:51:13 pm »
This query does not block EA - but it returns only objects that have the tag - and not the objects that are connected to objects with this tag.

The query shall fake somehow "tag inheritance" (EA.Element.TaggedValuesEx)
« Last Edit: January 24, 2019, 12:04:05 am by siaccarino »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Why does this SQL statement blocks my EA?
« Reply #3 on: January 24, 2019, 12:04:20 am »
This query does not block EA - but it returns only objects that have the tag - and not the objects that are connected to objects with this tag.

The query shall fake somehow "tag inheritance"
I know, that is exactly what I wrote:
Quote
This query selects all objects that have the tagged value, and a connector.
but it should give you a place to start from.

If you would like me to write the whole query for you according to your requirements, you can always hire me as a consultant.

Geert

Mauricio Moya (Arquesoft)

  • EA User
  • **
  • Posts: 344
  • Karma: +8/-4
  • EA Consulting and development in Spanish
    • View Profile
    • Arquehub Azure Module
Re: Why does this SQL statement blocks my EA?
« Reply #4 on: February 06, 2019, 11:26:49 am »
In my experience, EA locks when the query uses too much memory (and it is worse if your connection is via Cloud Server), but in most cases you just have to wait for the response. Just be patient. For certain size of the memory consumption in the database server, the Cloud Server could throws an error and no data is returned to the client.

The best way to solve it is, as they said in the previous posts, to optimize the query.