I found the profile(Goal) predicate and decided to use it on various queries. What are some ways that I can improve performance of these queries.
I ran the queries on a system with
Intel Core i5 4590 (4cores) 3.5 GHZ
24G Ram
See profiling of the queries below.
30 ?- profile((device(Id1,Price1,desktop,Model1,Brand1,Attr1,_),member(built_in_webcam_b=['yes'],Attr1),member(processor_number_of_cores=[Cores|_],Attr1),atom_number(Cores,Cores2),Cores2>=2,device(Id2,Price2,keyboard,Model2,Brand2,_,_),device(Id3,Price3,mouse,Model3,Brand3,Attr3,_),device(Id4,Price4,monitor,Model4,Brand4,_,_), TotalPrice is Price1+Price2+Price3+Price4,TotalPrice >=100,TotalPrice=<400)).
=====================================================================
Total time: 224.375 seconds
=====================================================================
Predicate Box Entries = Calls+Redos Time
=====================================================================
device/7 345,163,990 = 828,283+344,335,707 43.0%
is/2 344,335,024 =344,335,024+0 29.2%
=</2 344,335,024 =344,335,024+0 12.4%
>=/2 344,335,061 =344,335,061+0 8.9%
,/2 1 = 1+0 6.5%
atom_number/2 37 = 37+0 0.0%
lists:member_/3 832 = 758+74 0.0%
member/2 758 = 758+0 0.0%
false.
29 ?- profile((device(Id1,Price1,desktop,Model1,Brand1,Attr1,_),member(built_in_webcam_b=['yes'],Attr1),member(processor_number_of_cores=['4'],Attr1),device(Id2,Price2,keyboard,Model2,Brand2,_,_),device(Id3,Price3,mouse,Model3,Brand3,Attr3,_),device(Id4,Price4,monitor,Model4,Brand4,_,_), TotalPrice is Price1+Price2+Price3+Price4,TotalPrice >=100,TotalPrice=<400)).
=====================================================================
Total time: 178.547 seconds
=====================================================================
Predicate Box Entries = Calls+Redos Time
=====================================================================
device/7 270,534,094 = 649,195+269,884,899 44.8%
is/2 269,884,208 =269,884,208+0 27.7%
=</2 269,884,208 =269,884,208+0 11.7%
>=/2 269,884,208 =269,884,208+0 8.6%
,/2 1 = 1+0 7.2%
lists:member_/3 824 = 758+66 0.0%
member/2 758 = 758+0 0.0%
false.
29 ?- profile((device(Id1,Price1,desktop,Model1,Brand1,Attr1,_),member(built_in_webcam_b=['yes'],Attr1),member(processor_number_of_cores=['4'],Attr1),device(Id2,Price2,keyboard,Model2,Brand2,_,_),device(Id3,Price3,mouse,Model3,Brand3,Attr3,_),device(Id4,Price4,monitor,Model4,Brand4,_,_), TotalPrice is Price1+Price2+Price3+Price4,TotalPrice >=100,TotalPrice=<400)).
=====================================================================
Total time: 178.547 seconds
=====================================================================
Predicate Box Entries = Calls+Redos Time
=====================================================================
device/7 270,534,094 = 649,195+269,884,899 44.8%
is/2 269,884,208 =269,884,208+0 27.7%
=</2 269,884,208 =269,884,208+0 11.7%
>=/2 269,884,208 =269,884,208+0 8.6%
,/2 1 = 1+0 7.2%
lists:member_/3 824 = 758+66 0.0%
member/2 758 = 758+0 0.0%
false.
26 ?- profile((device(Id1,Price1,desktop,Model1,Brand1,Attr1,_),member(built_in_webcam_b=['yes'],Attr1),device(Id2,Price2,keyboard,Model2,Brand2,_,_),device(Id3,Price3,mouse,Model3,Brand3,Attr3,_),device(Id4,Price4,monitor,Model4,Brand4,_,_), TotalPrice is Price1+Price2+Price3+Price4,TotalPrice >=100,TotalPrice=<400)).
=====================================================================
Total time: 224.156 seconds
=====================================================================
Predicate Box Entries = Calls+Redos Time
=====================================================================
device/7 345,163,990 = 828,283+344,335,707 44.8%
is/2 344,335,024 =344,335,024+0 27.9%
=</2 344,335,024 =344,335,024+0 11.8%
>=/2 344,335,024 =344,335,024+0 9.0%
,/2 1 = 1+0 6.5%
lists:member_/3 758 = 721+37 0.0%
member/2 721 = 721+0 0.0%
false.
25 ?- profile((device(Id1,Price1,desktop,Model1,Brand1,Attr1,_),member(built_in_webcam_b=['yes'],Attr1),device(Id2,Price2,keyboard,Model2,Brand2,_,_),device(Id3,Price3,mouse,Model3,Brand3,Attr3,_),device(Id4,Price4,monitor,Model4,Brand4,_,_), TotalPrice is Price1+Price2+Price3+Price4,TotalPrice >=500,TotalPrice=<600)).
=====================================================================
Total time: 24.203 seconds
=====================================================================
Predicate Box Entries = Calls+Redos Time
=====================================================================
device/7 37,314,987 = 89,548+37,225,439 43.5%
is/2 37,225,415 =37,225,415+0 28.1%
=</2 37,225,415 =37,225,415+0 12.6%
>=/2 37,225,415 =37,225,415+0 10.1%
,/2 1 = 1+0 5.8%
lists:member_/3 34 = 30+4 0.0%
member/2 30 = 30+0 0.0%
Id1 = '58cec6679af27f6bc3c5e8c0',
Price1 = 447.99,
Model1 = 'BBY-CY44XFX',
Brand1 = 'Dell',
Attr1 = [processor_brand=[amd], number_of_ps2_ports=['0'], hard_drive_capacity=['500'], graphics_processing_unit_gpu=[amd], system_memory_ram_speed=['1600'], processor_model=['amd e2-series'], cache_memory=['2'], wireless_networking_b=['wireless-ac', 'wireless-ac (433 mbps)'], number_of_hdmi_output_ports=['1'], video_memory_type=[shared], display_type=['led-lcd'], graphics_type=[integrated], processor_speed=['1.8'], number_of_usb_ports=['4'], operating_system=['windows 10'], screen_size=['23.8'], processor_number_of_cores=['2'], built_in_webcam_b=[yes], brand=[dell], speakers_included_b=[yes], optical_drive_type=['dvd-r', 'dvd+r', 'dvd-rw', 'dvd+rw', 'cd-r', 'cd-rw'], port_types=[ethernet, usb, hdmi], system_memory_ram=['4'], screen_resolution=['1920 x 1080 (full hd)'], media_card_reader_b=[yes], graphics_card=['amd radeon r2'], bluray_player_b=[no], ethernet=['10/100/1000'], number_of_vga_ports=['0'], number_of_ethernet_ports=['1'], system_memory_ram_expandable_ports=['8'], has_bluetooth_enabled=[yes], operating_system_architecture=['64-bit'], multi_touch_screen_b=[no], audio_technology_b=['waves maxxaudio']],
Id2 = '58cec6679af27f6bc3c5e6af',
Price2 = 21.99,
Model2 = 'NS-PNK6811',
Brand2 = 'Insignia�',
Id3 = '58cec6679af27f6bc3c5e61a',
Price3 = 17.99,
Model3 = 'K72369US',
Brand3 = 'Kensington',
Attr3 = [ergonomic_design_b=[yes], interfaces=[usb], brand=[kensington]],
Id4 = '58cec6679af27f6bc3c5e677',
Price4 = 73.99,
Model4 = 'VS197DP',
Brand4 = 'Asus',
TotalPrice = 561.96.
24 ?- profile((device(Id1,Price1,desktop,Model1,Brand1,Attr1,_),device_attribute(Id1,built_in_webcam_b,yes),device(Id2,Price2,keyboard,Model2,Brand2,_,_),device(Id3,Price3,mouse,Model3,Brand3,_,_),device(Id4,Price4,monitor,Model4,Brand4,_,_), TotalPrice is Price1+Price2+Price3+Price4, TotalPrice >=200,TotalPrice=<500)).
=====================================================================
Total time: 135.563 seconds
=====================================================================
Predicate Box Entries = Calls+Redos Time
=====================================================================
device/7 205,237,029 = 492,507+204,744,522 45.5%
is/2 204,744,379 =204,744,379+0 27.7%
=</2 204,744,379 =204,744,379+0 11.3%
>=/2 204,744,379 =204,744,379+0 8.2%
,/2 1 = 1+0 7.2%
device_attribute/3 167 = 167+0 0.0%
Id1 = '58cec6679af27f6bc3c5eebf',
Price1 = 410.99,
Model1 = '22-B010',
Brand1 = 'HP',
Attr1 = [processor_brand=[amd], number_of_ps2_ports=['0'], hard_drive_capacity=['1000'], graphics_processing_unit_gpu=[amd], processor_model=['amd a6-series'], cache_memory=['2'], wireless_networking_b=['wireless-n'], number_of_hdmi_output_ports=['1'], video_memory_type=['total available'], display_type=['widescreen led'], graphics_type=[discrete], processor_speed=['2'], number_of_usb_ports=['4'], number_of_displayport_outputs=['0'], operating_system=['windows 10'], screen_size=['21.5'], processor_number_of_cores=['4'], built_in_webcam_b=[yes], brand=[hp], optical_drive_type=['dvd+rw dl'], video_resolution=['1920 x 1080'], port_types=['usb 2.0', 'usb 3.0', ethernet, hdmi, headphone, microphone], system_memory_ram=['4'], screen_resolution=['1920 x 1080 (full hd)'], media_card_reader_b=[yes], number_of_dvi_ports=['0'], graphics_card=['amd radeon r4'], ethernet=['ethernet; fast ethernet; gigabit ethernet'], number_of_vga_ports=['0'], number_of_ethernet_ports=['1'], has_bluetooth_enabled=[yes]],
Id2 = '58cec6679af27f6bc3c5e6af',
Price2 = 21.99,
Model2 = 'NS-PNK6811',
Brand2 = 'Insignia�',
Id3 = '58cec6679af27f6bc3c5e7f2',
Price3 = 15.99,
Model3 = 'GM2400',
Brand3 = 'AZIO',
Id4 = '58cec6679af27f6bc3c5e993',
Price4 = 49.99,
Model4 = 'UM.IS0AA.C02.RB1',
Brand4 = 'Acer',
TotalPrice = 498.96000000000004.