Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. client = TinyTds::Client.new username: ENV["SQL_SERVER_USERNAME"],
  2. password: ENV["SQL_SERVER_PASSWORD"],
  3. port: ENV["SQL_SERVER_PORT"],
  4. host: ENV["SQL_SERVER_HOST"],
  5. database: ENV["SQL_SERVER_DB"]
  6. query = "SELECT TOP(60000) [Institution of Higher Education Key]
  7.    ,[Date Key]
  8.      ,[Academic Term Key]
  9.      ,[IPEDS Demographics Key]
  10.      ,[IPEDS Fall Enrollment Attribute Key]
  11.      ,[IPEDS Enrollment Headcount]
  12.      ,[Calculated Full Time Equivalent Enrollment-Fall Headcount Basis]
  13.  FROM [dw].[IPEDS Fall Enrollment Fact]
  14. GO"
  15. result = client.execute("EXECUTE AS USER='ADND\\rsnodgra' #{query}")
  16. report = MemoryProfiler.report do
  17. CSV.open('dataset_exports/tinytds_memory_test.csv', 'w') do |csv|
  18. csv << result.fields
  19. result.each(:as => :array, :cache_rows => false) do |row|
  20. csv << row
  21. end
  22. end
  23. end
  24. report.pretty_print
  25.  
  26. # 74.449254 MB of memory
  27. allocated memory by gem
  28. -----------------------------------
  29. 41808214 ruby-2.1.8/lib
  30. 19200000 activesupport-4.1.15
  31. 13441040 other
  32.  
  33. allocated memory by file
  34. -----------------------------------
  35. 41808214 /usr/local/rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/csv.rb
  36. 16800000 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/activesupport-4.1.15/lib/active_support/core_ext/numeric/conversions.rb
  37. 13441040 (irb)
  38. 2400000 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/activesupport-4.1.15/lib/active_support/core_ext/big_decimal/conversions.rb
  39.  
  40.  
  41. #####################
  42. #####################
  43. #####################
  44. #####################
  45.  
  46. @db = Sequel.tinytds user: ENV["SQL_SERVER_USERNAME"],
  47. password: ENV["SQL_SERVER_PASSWORD"],
  48. port: ENV["SQL_SERVER_PORT"],
  49. host: ENV["SQL_SERVER_HOST"],
  50. database: ENV["SQL_SERVER_DB"],
  51. timeout: 20
  52. query = "SELECT TOP(60000) [Institution of Higher Education Key]
  53.    ,[Date Key]
  54.      ,[Academic Term Key]
  55.      ,[IPEDS Demographics Key]
  56.      ,[IPEDS Fall Enrollment Attribute Key]
  57.      ,[IPEDS Enrollment Headcount]
  58.      ,[Calculated Full Time Equivalent Enrollment-Fall Headcount Basis]
  59.  FROM [dw].[IPEDS Fall Enrollment Fact]
  60. GO"
  61.  
  62. report = MemoryProfiler.report do
  63. CSV.open('dataset_exports/sequel_memory_test.csv', 'w') do |csv|
  64. csv << @db["EXECUTE AS USER='ADND\\rsnodgra'; #{query}"].first.keys
  65. @db["EXECUTE AS USER='ADND\\rsnodgra'; #{query}"].each do |row|
  66. csv << row.values
  67. end
  68. end
  69. end
  70. report.pretty_print
  71.  
  72. # 105.182268 MB
  73. Total allocated: 105182268 bytes (1440296 objects)
  74. Total retained: 1411 bytes (12 objects)
  75.  
  76. allocated memory by gem
  77. -----------------------------------
  78. 41808494 ruby-2.1.8/lib
  79. 38411103 sequel-4.35.0
  80. 19200000 activesupport-4.1.15
  81. 5761534 other
  82. 1137 tiny_tds-1.0.4
  83.  
  84. allocated memory by file
  85. -----------------------------------
  86. 41808494 /usr/local/rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/csv.rb
  87. 38405678 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/sequel-4.35.0/lib/sequel/adapters/tinytds.rb
  88. 16800000 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/activesupport-4.1.15/lib/active_support/core_ext/numeric/conversions.rb
  89. 5761534 (irb)
  90. 2400000 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/activesupport-4.1.15/lib/active_support/core_ext/big_decimal/conversions.rb
  91. 2441 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/sequel-4.35.0/lib/sequel/dataset/actions.rb
  92. 1352 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/sequel-4.35.0/lib/sequel/dataset/query.rb
  93. 1137 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/tiny_tds-1.0.4/lib/tiny_tds/client.rb
  94. 1008 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/sequel-4.35.0/lib/sequel/database/connecting.rb
  95. 464 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/sequel-4.35.0/lib/sequel/connection_pool/threaded.rb
  96. 160 /usr/local/rvm/gems/ruby-2.1.8@Fenrir/gems/sequel-4.35.0/lib/sequel/database/dataset.rb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement