{
    "mode": "perldoc",
    "parameter": "DBI::ProfileDumper::Apache",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/DBI%3A%3AProfileDumper%3A%3AApache/json",
    "generated": "2026-10-04T10:00:59Z",
    "synopsis": "Add this line to your httpd.conf:\nPerlSetEnv DBIPROFILE 2/DBI::ProfileDumper::Apache\n(If you're using modperl2, see \"When using modperl2\" for some additional notes.)\nThen restart your server. Access the code you wish to test using a web browser, then shutdown\nyour server. This will create a set of dbi.prof.* files in your Apache log directory.\nGet a profiling report with dbiprof:\ndbiprof /path/to/your/apache/logs/dbi.prof.*\nWhen you're ready to perform another profiling run, delete the old files and start again.",
    "sections": {
        "NAME": {
            "content": "DBI::ProfileDumper::Apache - capture DBI profiling data from Apache/modperl\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "Add this line to your httpd.conf:\n\nPerlSetEnv DBIPROFILE 2/DBI::ProfileDumper::Apache\n\n(If you're using modperl2, see \"When using modperl2\" for some additional notes.)\n\nThen restart your server. Access the code you wish to test using a web browser, then shutdown\nyour server. This will create a set of dbi.prof.* files in your Apache log directory.\n\nGet a profiling report with dbiprof:\n\ndbiprof /path/to/your/apache/logs/dbi.prof.*\n\nWhen you're ready to perform another profiling run, delete the old files and start again.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module interfaces DBI::ProfileDumper to Apache/modperl. Using this module you can collect\nprofiling data from modperl applications. It works by creating a DBI::ProfileDumper data file\nfor each Apache process. These files are created in your Apache log directory. You can then use\nthe dbiprof utility to analyze the profile files.\n",
            "subsections": []
        },
        "USAGE": {
            "content": "LOADING THE MODULE\nThe easiest way to use this module is just to set the DBIPROFILE environment variable in your\nhttpd.conf:\n\nPerlSetEnv DBIPROFILE 2/DBI::ProfileDumper::Apache\n\nThe DBI will look after loading and using the module when the first DBI handle is created.\n\nIt's also possible to use this module by setting the Profile attribute of any DBI handle:\n\n$dbh->{Profile} = \"2/DBI::ProfileDumper::Apache\";\n\nSee DBI::ProfileDumper for more possibilities, and DBI::Profile for full details of the DBI's\nprofiling mechanism.\n\nWRITING PROFILE DATA\nThe profile data files will be written to your Apache log directory by default.\n\nThe user that the httpd processes run as will need write access to the directory. So, for\nexample, if you're running the child httpds as user 'nobody' and using chronolog to write to the\nlogs directory, then you'll need to change the default.\n\nYou can change the destination directory either by specifying a \"Dir\" value when creating the\nprofile (like \"File\" in the DBI::ProfileDumper docs), or you can use the\n\"DBIPROFILEAPACHELOGDIR\" env var to change that. For example:\n\nPerlSetEnv DBIPROFILEAPACHELOGDIR /serverroot/logs\n\nWhen using modperl2\nUnder modperl2 you'll need to either set the \"DBIPROFILEAPACHELOGDIR\" env var, or enable\nthe modperl2 \"GlobalRequest\" option, like this:\n\nPerlOptions +GlobalRequest\n\nto the global config section you're about test with DBI::ProfileDumper::Apache. If you don't do\none of those then you'll see messages in your errorlog similar to:\n\nDBI::ProfileDumper::Apache ondestroy failed: Global $r object is not available. Set:\nPerlOptions +GlobalRequest in httpd.conf at ..../DBI/ProfileDumper/Apache.pm line 144\n\nNaming the files\nThe default file name is inherited from DBI::ProfileDumper via the filename() method, but\nDBI::ProfileDumper::Apache appends the parent pid and the current pid, separated by dots, to\nthat name.\n\nSilencing the log\nBy default a message is written to STDERR (i.e., the apache errorlog file) when flushtodisk()\nis called (either explicitly, or implicitly via DESTROY).\n\nThat's usually very useful. If you don't want the log message you can silence it by setting the\n\"Quiet\" attribute true.\n\nPerlSetEnv DBIPROFILE 2/DBI::ProfileDumper::Apache/Quiet:1\n\n$dbh->{Profile} = \"!Statement/DBI::ProfileDumper/Quiet:1\";\n\n$dbh->{Profile} = DBI::ProfileDumper->new(\nPath => [ '!Statement' ]\nQuiet => 1\n);\n\nGATHERING PROFILE DATA\nOnce you have the module loaded, use your application as you normally would. Stop the webserver\nwhen your tests are complete. Profile data files will be produced when Apache exits and you'll\nsee something like this in your errorlog:\n\nDBI::ProfileDumper::Apache writing to /usr/local/apache/logs/dbi.prof.2604.2619\n\nNow you can use dbiprof to examine the data:\n\ndbiprof /usr/local/apache/logs/dbi.prof.2604.*\n\nBy passing dbiprof a list of all generated files, dbiprof will automatically merge them into one\nresult set. You can also pass dbiprof sorting and querying options, see dbiprof for details.\n\nCLEANING UP\nOnce you've made some code changes, you're ready to start again. First, delete the old profile\ndata files:\n\nrm /usr/local/apache/logs/dbi.prof.*\n\nThen restart your server and get back to work.\n",
            "subsections": []
        },
        "OTHER ISSUES": {
            "content": "",
            "subsections": [
                {
                    "name": "Memory usage",
                    "content": "DBI::Profile can use a lot of memory for very active applications because it collects profiling\ndata in memory for each distinct query run. Calling flushtodisk() will write the current data\nto disk and free the memory it's using. For example:\n\n$dbh->{Profile}->flushtodisk() if $dbh->{Profile};\n\nor, rather than flush every time, you could flush less often:\n\n$dbh->{Profile}->flushtodisk()\nif $dbh->{Profile} and ++$i % 100;\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "Sam Tregar <sam@tregar.com>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "Copyright (C) 2002 Sam Tregar\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl 5 itself.\n",
            "subsections": []
        }
    },
    "summary": "DBI::ProfileDumper::Apache - capture DBI profiling data from Apache/modperl",
    "flags": [],
    "examples": [],
    "see_also": []
}