Lesson Learned #56: External tables and performance issues

Hello Team,

Recently I closed a service request that had the following question

  • Our customer created external tables to perform SQL Query across Azure SQL Database. We suggested to use Azure SQL Managed Instance (because there is not needed to use external tables to access to other databases using the same connection) in order to avoid it, but, our customer wanted to continue working with Azure SQL Database.
    • In this case, when our customer perform the following query using external tables the performance is slow and they need an explanation what can be wrong.
    • I explained:
      • Step 1: The time spent is expected, mostly, when you executed the first time the query of an External Table, because, internally, a  component needs to retrieve the data. For this reason, I would like to suggest two alternatives, but, let me explain what is happening:
        Suppose that I’m executing the following TSQL is an External Data:
     Select * INTO jUAN1 from PerformanceVarcharNVarchar Where texttosearch like '%20000--2%' where PerformanceVarcharNVarchar
      • Enabling the Actual Execution plan of the query option, you could see that the query ( Select * from PerformanceVarcharNVarchar) bring the data to the temporal database from the external database and after the engine will be apply the filter. So, that means that if the table has 700.000 rows, the query will retrieve 700.000 to the temporal database and after it will apply the filter specified.

    @data_source_name = N'RemoteReferenceData',
    @stmt= N'Select Id from PerformanceVarcharNVarchar Where texttosearch like @Value',
    @Params = N'@Value varchar(200)',


    Comments (0)

    Skip to main content