Skip to main content
Question

SQL executor - Workspace very slow


nelson
Participant
Forum|alt.badge.img

Hello,

I'm using a SQL Executor transformer in my workspace. It is very very very slow (10 features in 10 minutes, I have 200 000 features to read).

I have 2 readers and 1 writer from PostgreSQL spatial tables. I created indexes in geom attribute (gist) and primary key (btree) for the 2 readers.

The SQL script is :

update ref_assainissement.fildo SET nodterrain = 't'

 

FROM ref_assainissement.canaexp

 

WHERE idfildo = idfildoaval OR idfildo = idfildoamont

(so very simple)

Any idea ?

 

Thank you !

 

14 replies

david_r
Celebrity
  • July 20, 2020

Make 100% sure that you have an index on the field "idfildo" in the table you're updating. That will almost always make a huge difference.


nelson
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • July 21, 2020

Thank you for your answer.

 

I created an index on idfildo, the project runs still slowly.

 

I have this alert message :

"The project may run slowly because the attributes are being saved on all output ports."


david_r
Celebrity
  • July 21, 2020

Have you switched off feature caching in the workspace?

See https://knowledge.safe.com/articles/79739/feature-caching-and-performance.html


nelson
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • July 21, 2020

Yes I switched off feature caching in the workspace.

Maybe I need to index the fields idfildoamaont and idfildoaval too ?

 

If it is not working, maybe I can use the DatabaseUpadter transformer ?


david_r
Celebrity
  • July 21, 2020

If ref_assainissement.canaexp is a regular table, then indexing idfiloaval and idfildoamont would probably not make a difference.

You can always try the DatabaseUpdater, but there is no logical reason (to me) why it should make a big difference, although I'd love to hear if that is the case!

What happens if you disable the SQLExecutor and then run the workspace? Is it still slow, or suddenly much faster? The idea is to get a feeling for how much time the update operations is taking.


nelson
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • July 21, 2020

It takes 21 secondes if a I disable the SQL Executor.

What about this message ? "The project may run slowly because the attributes are being saved on all output ports."


david_r
Celebrity
  • July 21, 2020
nelson wrote:

It takes 21 secondes if a I disable the SQL Executor.

What about this message ? "The project may run slowly because the attributes are being saved on all output ports."

Can you show this message in a context? Screen grab, e.g.

It usually means that feature caching is ON.


david_r
Celebrity
  • July 21, 2020

Just a question: how many features are entering the SQLExecutor?

Since I cannot see any references to feature attributes in the SQL command, I would say that only one feature should enter, since otherwise you're simply executing the exact same command many times.


nelson
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • July 21, 2020

Sorry I don't understand your comment.

 

About 100 000 feature for each reader.

 

It's working with 2 featuremerger and attributecreator.

 

 


david_r
Celebrity
  • July 21, 2020

Bonjour, vous préférez peut-être une réponse en français? Ma question était: en regardant le code SQL dans votre SQLExecutor, je ne vois aucune référence à un attribut FME. Ma conclusion est donc que le code SQL reste inchangé d'un feature à l'autre, et dans ce cas je ne comprends pas pourquoi vous allez exécuter exactment la même commande 200'000 fois -- est-ce nécessaire? Ou est-ce que j'ai mal compris?


nelson
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • July 21, 2020

Herre is the information message :


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • July 21, 2020

If you are using the sql executor, you don't need to read the PostgreSQL spatial tables, you just need a single trigger feature to execute the query once (or an SQLCreator)

 


nelson
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • July 21, 2020
david_r wrote:

Bonjour, vous préférez peut-être une réponse en français? Ma question était: en regardant le code SQL dans votre SQLExecutor, je ne vois aucune référence à un attribut FME. Ma conclusion est donc que le code SQL reste inchangé d'un feature à l'autre, et dans ce cas je ne comprends pas pourquoi vous allez exécuter exactment la même commande 200'000 fois -- est-ce nécessaire? Ou est-ce que j'ai mal compris?

Oui en français c'est mieux mais la question reste floue :)

Pourquoi devrais-je faire référence à un attribut FME ?

Je veux mettre à jour tous les objets de ce champ avec cette requête, comme je le ferai directement en SQL dans un outil d'admistration de données (PGAdmin par exple).

 


david_r
Celebrity
  • July 21, 2020
nelson wrote:

Oui en français c'est mieux mais la question reste floue :)

Pourquoi devrais-je faire référence à un attribut FME ?

Je veux mettre à jour tous les objets de ce champ avec cette requête, comme je le ferai directement en SQL dans un outil d'admistration de données (PGAdmin par exple).

 

Avec le workspace actuel, le code SQL est exécuté une fois pour chaque enregistrement (feature) lu des tables Postgresql. Par contre, le code SQL agit sur toute la table d'un coup. Alors je pense qu'il n'est pas nécessaire de l'exécuter plus qu'un seule fois, voir la suggestion de @ebygomm


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings