Skip to content

SQL: slow parsing of certain SQL files #3647

Closed
@techee

Description

We got a bug report here geany/geany-osx#42 (comment) in Geany where Geany stopped responding for very long time for not so large SQL file (~16000 LOCs). I bisected this problem to this commit:

4dbda62

Basically the problem isn't the commit itself but rather that string which is passed to this function and which should contain just the current token seems to contain a huge amount of the SQL code and not just a single token (I haven't checked the size but it certainly is hundreds of characters long). As this string is getting bigger, lookupCaseKeyword() is called every time a charactger is added in

if (empty_tag
    && KEYWORD_inquiry_directive == lookupCaseKeyword (vStringValue (string), Lang_sql))

which consumes a lot of time. A simple workaround which reduces the parsing time significantly is to check the size of the string against some constant corresponding to the longest keyword:

if (empty_tag && string->length < 20
    && KEYWORD_inquiry_directive == lookupCaseKeyword (vStringValue (string), Lang_sql))

Still, it would be good to investigate what the reason behind the long token is and fix it properly.

I assume that @cloudis-ild could send the file causing this issue privately or I could send it as well if he agrees.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions