@rit372002 When you use SQL Statement directly to import the data from Database then Native Query(Query folding) is disabled, In your scenario Power Query is bringing huge amount of Data and then making transformation within Power Query instead of sending the Query back to the Data Source and making transformations there.
Use Value.NativeQuery to enable Query Folding