{"id":6961,"date":"2022-05-07T02:04:15","date_gmt":"2022-05-07T02:04:15","guid":{"rendered":"https:\/\/www.directimpactsolutions.com\/?p=6961"},"modified":"2025-05-01T03:42:53","modified_gmt":"2025-05-01T03:42:53","slug":"table-size-filemaker","status":"publish","type":"post","link":"https:\/\/www.directimpactsolutions.com\/en\/table-size-filemaker\/","title":{"rendered":"How to Measure Table Size in FileMaker"},"content":{"rendered":"<p>Have you ever wondered which tables in your database are taking up storage space on your server? Perhaps you want to monitor how fast your table size is increasing in order to work out an archiving strategy for controlling storage space consumption.<\/p><p>This article will demonstrate a technique that creates a modular, portable script that can be copied and pasted into any FileMaker solution to measure table size. This can help you control your solution storage size.<\/p><h2 class=\"wp-block-heading\" id=\"How-do-we-measure-table-sizes?\">How to Measure Table Size<\/h2><p>Let\u2019s start by talking about how we measure table size. This method for measurement can be compared to the way I measure my cat\u2019s weight:<\/p><p>I hold my cat, measure our combined weight on the scale, put him down, and then measure the weight on the scale again. The difference between the two measurements is my cat\u2019s weight.<\/p><p>When we measure table size, we save a compacted copy of the database, measure its size, truncate the table we want to measure, save another compacted copy, and measure the size again. Then the difference between the two measurements is roughly the size of the table.<\/p><h2 class=\"wp-block-heading\" id=\"How-do-we-automate-this?\">How can we automate this?<\/h2><p>So now we know how to measure the size of one table, but I don\u2019t want to do this manually. I want to measure and record the size automatically. How do we do that? The simplest solution is to use a script to do these steps for me.<\/p><p>To save a compacted copy, we can use the script step \u201cSave a Copy As\u201d and specify the option to be \u201cCompacted Copy&#8221;:<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"584\" height=\"29\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-1.png\" alt=\"measure table size\" class=\"wp-image-6968\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-1.png 584w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-1-300x15.png 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-1-480x24.png 480w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/figure><p>To truncate a table, we can use the Truncate table script step:<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"393\" height=\"24\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-2.png\" alt=\"table size filemaker script\" class=\"wp-image-6970\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-2.png 393w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-2-300x18.png 300w\" sizes=\"auto, (max-width: 393px) 100vw, 393px\" \/><\/figure><p>To measure the size of the compacted copy, we can use the Get File Size script step:<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"409\" height=\"28\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-3.png\" alt=\"FileMaker table size step 3\" class=\"wp-image-6972\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-3.png 409w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-3-300x21.png 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-3-400x28.png 400w\" sizes=\"auto, (max-width: 409px) 100vw, 409px\" \/><\/figure><p>Combining them gives me an automated workflow that will save, measure, truncate, save, measure, and compare.<\/p><h2 class=\"wp-block-heading\" id=\"How-to-do-this-dynamically?\">How can we do this dynamically?<\/h2><p>Unfortunately, the Truncate Table script step does not allow us to specify a calculated table name as a parameter. This means we either have to create many copies of the block of script steps we just saw, one for each table, or we need to figure out a way to truncate tables dynamically. This brings me to step 3, making this process dynamic, modular, and portable.<\/p><p>As mentioned earlier, the constraint is that the Truncate Table script step does not support dynamic input. However, it does have the option to truncate the current table. If I can go to at least one layout per table, I can truncate them all.<\/p><p>So now the challenge is to figure out a way to go to one layout per table. We can easily get a list of all layouts in the system by using the design function <em>LayoutNames<\/em>, and the <em>Go To Layout<\/em> script step supports dynamic input, meaning you can go to a layout by name. Combining those two will allow us to cover all layouts in the system. If we assume that each table we want to measure has at least one layout, this method will achieve our goal.<\/p><h3 class=\"wp-block-heading\" id=\"Get-a-list-of-all-base-table-names\">Getting a List of all Base Table Names<\/h3><p>Let\u2019s optimize this just a little bit. In a FileMaker system, we all know it\u2019s very common for one table to have many table occurrences based on it. We also know that each table occurrence can have many layouts based on it. We don\u2019t need to perform a truncate table on all of them; we just need to do it once. In my script, I added a mechanism to register which tables have been truncated or measured. If a table has been measured already, we can skip it the next time we land on a layout based on it.<\/p><p>I\u2019m using the <em>ExecuteSQL<\/em> function to query a FileMaker system table to get all base table names. This is kind of a hidden functionality of the <em>ExecuteSQL<\/em> function; it allows you to query the metadata of your database, like TO names, base table names, and field names.<\/p><p>Here is a link to the <a href=\"https:\/\/help.claris.com\/en\/sql-reference.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">FileMaker SQL reference<\/a>, which explains this in more detail. In the reference, go to the chapter named FileMaker system objects, and you\u2019ll see how to use this.<\/p><h3 class=\"wp-block-heading\" id=\"Cross-off-item-from-the-list-after-it\u2019s-measured\">Crossing Items Off After Measurement<\/h3><p>Now that I have a list of base table names, I need a way to cross them off one by one. To do that, I need to know which base table a layout is based on.<\/p><p>This sounds more trivial than it is. We have the function <em>Get (LayoutTableName)<\/em>. However, this function returns the table occurrence name instead of the base table name that the layout is based on.<\/p><p>To get the base table name, I\u2019ll need to use the ExecuteSQL function again to query the system tables and find out which base table the table occurrence is based on.<\/p><p>With the ability to get the base table name of a layout, we can remove the corresponding base table name from the list every time we measure one. So the next time we run into a layout based on the same base table, we can skip it.<\/p><h2 class=\"wp-block-heading\" id=\"Putting-everything-together\">Putting everything together<\/h2><p>Now let\u2019s put everything together.<\/p><p>We start by dynamically getting a list of all base table names to help us track what to measure.<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"91\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-4.png\" alt=\"table size in FileMaker\" class=\"wp-image-6996\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-4.png 973w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-4-300x28.png 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-4-768x72.png 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-4-480x45.png 480w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/figure><p>Then we use a loop to go through all layouts in the system. For each layout, if it\u2019s based on a base table that hasn\u2019t been measured, we will measure the file size, truncate that table, then measure again and calculate the truncated table size. And we cross off this base table from our list, so it doesn\u2019t get measured again.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"914\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/image-20220514-154935-1024x914.png\" alt=\"\" class=\"wp-image-7119\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/image-20220514-154935-1024x914.png 1024w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/image-20220514-154935-300x268.png 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/image-20220514-154935-768x686.png 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/image-20220514-154935-1080x964.png 1080w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/image-20220514-154935-980x875.png 980w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/image-20220514-154935-480x428.png 480w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/image-20220514-154935.png 1211w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><p>In the end, we save the log to the user\u2019s desktop path as a CSV file, using FileMaker Data File script steps.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"222\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-6-1024x222.png\" alt=\"Claris FileMaker table sizing\" class=\"wp-image-7000\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-6-1024x222.png 1024w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-6-300x65.png 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-6-768x166.png 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-6-1080x234.png 1080w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-6-980x212.png 980w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-6-480x104.png 480w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/table-size-filemaker-6.png 1241w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><p>Everything in here is FileMaker native. No plugins or custom functions are used, which means it can be easily copied and pasted into any file.<\/p><p>Here\u2019s demo file that contains the full script:<\/p><div class=\"wp-block-file\"><a id=\"wp-block-file--media-dadb72cc-cd34-411c-bd7f-5b88fc4f3cb5\" href=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/03\/Get_Size_of_All_Tables_Demo-File_v1_3.zip\">Get_Size_of_All_Tables_Demo-File_v1_3<\/a><a href=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/03\/Get_Size_of_All_Tables_Demo-File_v1_3.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-dadb72cc-cd34-411c-bd7f-5b88fc4f3cb5\">Download<\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>Have you ever wondered which tables in your database are taking up storage space on your server? Perhaps you want to monitor how fast your table size is increasing in order to work out an archiving strategy for controlling storage space consumption. This article will demonstrate a technique that creates a modular, portable script that &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.directimpactsolutions.com\/en\/table-size-filemaker\/\"> <span class=\"screen-reader-text\">How to Measure Table Size in FileMaker<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":11,"featured_media":7052,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","footnotes":""},"categories":[29],"tags":[112],"class_list":["post-6961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-low-code","tag-table-size"],"uagb_featured_image_src":{"full":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker.jpg",1300,736,false],"thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker-150x150.jpg",150,150,true],"medium":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker-300x170.jpg",300,170,true],"medium_large":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker-768x435.jpg",768,435,true],"large":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker-1024x580.jpg",1024,580,true],"1536x1536":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker.jpg",1300,736,false],"2048x2048":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker.jpg",1300,736,false],"woocommerce_thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker-300x300.jpg",300,300,true],"woocommerce_single":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker.jpg",600,340,false],"woocommerce_gallery_thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2022\/05\/measuring-table-in-filemaker-100x100.jpg",100,100,true]},"uagb_author_info":{"display_name":"Weihao Ding","author_link":"https:\/\/www.directimpactsolutions.com\/en\/author\/weihao-dingdirectimpactsolutions-com\/"},"uagb_comment_info":0,"uagb_excerpt":"Have you ever wondered which tables in your database are taking up storage space on your server? Perhaps you want to monitor how fast your table size is increasing in order to work out an archiving strategy for controlling storage space consumption. This article will demonstrate a technique that creates a modular, portable script that&hellip;","_links":{"self":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/6961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/comments?post=6961"}],"version-history":[{"count":16,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/6961\/revisions"}],"predecessor-version":[{"id":20014,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/6961\/revisions\/20014"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/media\/7052"}],"wp:attachment":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/media?parent=6961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/categories?post=6961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/tags?post=6961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}