Skip to content
Advertisement

Pyodbc and AWS Lambda

I have a fairly simple SQL query that’s taking forever to run in my Lambda function and I don’t know why. I know OR statements can be a killer in SQL, but in my database editor, it runs in about 800ms. Why would it take longer in a Lambda function?

I’m using cursor.execute() and passing the SQL statement.
SQL Query:

      select * 
            from dbo.housing
            where App_date >= (select notification_date from dbo.hub_notification_log where object_name = 'HOUSING_ASSIGN')
                    or Application_Complete >= (select notification_date from dbo.hub_notification_log where object_name = 'HOUSING_ASSIGN')
                    or Application_Cancel_Date >= (select notification_date from dbo.hub_notification_log where object_name = 'HOUSING_ASSIGN')
                    or MoveIn_Date >= (select notification_date from dbo.hub_notification_log where object_name = 'HOUSING_ASSIGN')
                    or Check_Out >= (select notification_date from dbo.hub_notification_log where object_name = 'HOUSING_ASSIGN')

Any insight would be appreciated!

Advertisement

Answer

Turns out this was an issue with my SQL Server table hub_notification_log. The AWS user account querying the data could not access the table and I ended up having to create a new table with a similar structure and re-apply the permissions for the AWS user account. I’m not entirely certain what the difference was between the two tables and permissions, but it seems to work well now. Thanks @mechanical_meat for your insight and attempting to help me out. I appreciate it!

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement