+ Start a Discussion
cduncombe44cduncombe44 

Possible inefficient SOQL queries HELP

Hello,

 

   I have created a page that is really just a big list of Processes (custom object) where the user can go and take ownership of the process, it is then removed from the master queue.

 

The page has 5 buttons to change the view View All, View Mine (open), View Mine (Completed), View Oither (open), View Others (Completed).  All this is really doing is changes a controller property that sets the visibility of my tables.

 

The problem is it takes FOREVER to render the different lists when pressing buttons.  It works fine testing in the sandbox with only a few dummy processes, but in production with 1000 or so, it takes forever.  I think I am doing something wrong with the SOQL queries perhaps.  Is there a more efficient way of accomplishing this?  

 

VF 

 

<apex:sectionHeader title="Insurance Profile Campaign" subtitle="Master List"/>
	<apex:form >
	<apex:outputpanel id="container">
	<apex:outputpanel id="table">	
	<apex:pageblock >
	<apex:pageBlockButtons location="top">
		<apex:commandLink action="{!viewAll}" value="View All Unassigned" styleClass="btn" style="text-decoration:none" id="all" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewMine}" value="View Mine (Open)" styleClass="btn" style="text-decoration:none" id="viewMine" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewOthers}" value="View Others (Open)" styleClass="btn" style="text-decoration:none" id="others" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewMyCompleted}" value="View Mine (Completed)" styleClass="btn" style="text-decoration:none" id="myComp" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewOtherCompleted}" value="View Others (Completed)" styleClass="btn" style="text-decoration:none" id="otherComp" rerender="table,mine,container"/>	
	</apex:pageBlockButtons>
	
	<apex:pageBlockTable value="{!allProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show All'}">
      
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>	
	
	</apex:pageBlockTable>
	
	<apex:pageBlockTable value="{!myProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show Mine'}">
		
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
		
	</apex:pageBlockTable>
	
	<apex:pageBlockTable value="{!otherProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show Others'}">		
        
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
	
	</apex:pageBlockTable>
	
	<apex:pageBlockTable value="{!myCompletedProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show My Completed'}">
		
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>	
	
	</apex:pageBlockTable>
	
	<apex:pageBlockTable value="{!otherCompletedProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show Other Completed'}">
		
       		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
		
	</apex:pageBlockTable>
	
	</apex:pageblock>	
	</apex:outputpanel>
	
	</apex:form>

</apex:page>

 

Controller

List<Process__c> allPros;
	List<Process__c> myPros;
	List<Process__c> otherPros;
	List<Process__c> myCompletedPros;
	List<Process__c> otherCompletedPros;
	Transient List<Task> acts;
	Public Process__c selectedProcess {get;set;}
	Public String Filter {get;set;}
	Public boolean showStep {get;set;}
	Public Process_Step__c step;
	Public Contact con {get;set;} 	

	public InsuranceCampaignMasterController() {
		
		acts = new List<Task>();
		selectedProcess = new Process__c();
		step = new Process_Step__c();
		Filter = 'Show All';
		ShowStep = false;
		con = new Contact();
	}

	public List<Process__c> getAllProcesses() {

		if(allPros == null) {
			allPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__r.Name = 'Chris Duncombe' and Status__c != 'Completed' 
				Order By Contact__r.MailingCity ASC];
									
		}return allPros;
	}
	
	public List<Process__c> getMyProcesses() {		
		
		if(myPros == null) {
			myPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__c =: userinfo.getUserId() 
				and Status__c != 'Completed' Order By Start_Date__c ASC];
		
		}return myPros;
	}
	
	public List<Process__c> getOtherProcesses() {		
		
		if(otherPros == null) {
			otherPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__c !=: userinfo.getUserId() 
				and Process_Owner__r.Name != 'Chris Duncombe' and Status__c != 'Completed' Order By Process_Owner__r.Name, Start_Date__c ASC];
		
		}return otherPros;
	}
	
	public List<Process__c> getMyCompletedProcesses() {
		
		if(myCompletedPros == null) {
			myCompletedPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c,
				Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__r.Name = 'Insurance Profile Campaign' 
				and Process_Owner__c =: userinfo.getUserId() and Status__c = 'Completed' Order By Completion_Date__c];
		
		}return myCompletedPros;
	}
	
	public List<Process__c> getOtherCompletedProcesses() {
		
		if(otherCompletedPros == null) {
			otherCompletedPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c,
				Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__r.Name = 'Insurance Profile Campaign' 
				and Process_Owner__c !=: userinfo.getUserId() and Process_Owner__r.Name != 'Chris Duncombe' and Status__c = 'Completed'
				Order By Process_Owner__r.Name, Completion_Date__c ASC];
		
		}return otherCompletedPros;
	}
	
	public void takeOwnership() {
		
		selectedProcess = [Select Id, Name, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c 
									From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
									
		step = [Select Id, Name, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		
		selectedProcess.Process_Owner__c = userinfo.getUserId();
		selectedProcess.Start_Date__c = system.today();
		step.Assigned_To__c = userinfo.getUserId();
		update selectedProcess;
		update step;
		myPros = null;		
	}
	
	public void setStep() {
		
		showStep = true;
		selectedProcess = [Select Id, Name, Contact__c, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c
				 					From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
										
		step = [Select Id, Name, Process__c, Complete_Step_From_Process__c, Log_Activity_From_Process__c, Create_Task_From_Process__c, Status__c,
								Completed_By__c, Date_Completed__c, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		con = [Select Id, Name From Contact Where id =: SelectedProcess.Contact__c];		
	}  
	
	public process_Step__c getMyStep() {
		return step;
	}
	
	public List<Task> getStepActivities() {
		acts = [Select Id, Subject, Navigator_Subject__c, ActivityDate, Description, WhoId, OwnerId, WhatId From Task Where WhatId =: step.id];
		return acts;
	}
	
	public void saveProcessChanges() {
		update selectedProcess;
	}
	
	public void viewMine() {
		Filter = 'Show Mine';
		showStep = false;
		
	}
	public void viewAll() {
		Filter = 'Show All';
		showStep = false;
		
	}
	public void viewOthers() {
		Filter = 'Show Others';
		showStep = false;
		
	}	
	public void viewMyCompleted() {
		Filter = 'Show My Completed';
		showStep = false;
		
	}
	public void viewOtherCompleted() {
		Filter = 'Show Other Completed';
		showStep = false;
		
	}
}

 

Any help would be greatly appreicated

 

Chris

Best Answer chosen by Admin (Salesforce Developers) 
cduncombe44cduncombe44

 

I found that it was definitely a rendering issue, not a SOQL issue.  The constant rerendering of a DataTable with 1000 or so records was causing very slow ajax rerendering.

 

I was able to solve the problem through the suggestion of the dynamic query, as well as adding some pagination by using the OFFSET in my SOQL.  I was able to do this rather easily using this great blog post from RedPointSolutions

 

http://blog.redpointsolutions.com/bid/182738/Add-Pagination-to-your-Visualforce-Pages-using-the-SOQL-OFFSET-Clause

 

 

Heres the final code if anyone might be interested

 

 

VF

<apex:page controller="testController">

<apex:sectionHeader title="Insurance Profile Campaign" subtitle="Master List"/>
    <apex:form >
    <apex:outputpanel id="container">
    <apex:outputpanel id="table">   
    <apex:pageblock >
    <apex:pageBlockButtons location="top">
        <apex:commandLink action="{!viewAll}" value="View All Unassigned" styleClass="btn" style="text-decoration:none" id="all" rerender="container,table"/>
        <apex:commandLink action="{!viewMine}" value="View Mine (Open)" styleClass="btn" style="text-decoration:none" id="viewMine" rerender="container,table"/>
        <apex:commandLink action="{!viewOthers}" value="View Others (Open)" styleClass="btn" style="text-decoration:none" id="others" rerender="container,table"/>
        <apex:commandLink action="{!viewMyCompleted}" value="View Mine (Completed)" styleClass="btn" style="text-decoration:none" id="myComp" rerender="container,table"/>
        <apex:commandLink action="{!viewOtherCompleted}" value="View Others (Completed)" styleClass="btn" style="text-decoration:none" id="otherComp" rerender="container,table"/>    
    </apex:pageBlockButtons>
    </apex:pageblock>
    <apex:pageblock tabStyle="Account">
    <apex:pageBlockButtons location="top" >
    <apex:outputPanel id="myButtons">
   
        <apex:commandButton action="{!Beginning}" title="Beginning" value="<<" style="width:35px;" disabled="{!disablePrevious}" reRender="myPanel,myButtons"/>
        <apex:commandButton action="{!Previous}" title="Previous" value="<" style="width:25px;" disabled="{!disablePrevious}" reRender="myPanel,myButtons"/>        
        <apex:commandButton action="{!Next}" title="Next" value=">" style="width:25px;" disabled="{!disableNext}" reRender="myPanel,myButtons"/>
        <apex:commandButton action="{!End}" title="End" value=">>" style="width:35px;" disabled="{!disableNext}" reRender="myPanel,myButtons"/>        
   
    </apex:outputPanel>
    </apex:pageBlockButtons>
    
    
    <apex:outputpanel id="myPanel">
    <apex:pageBlockSection title="{!listTitle}({!totalSize})" collapsible="false" columns="1">
    <apex:pageBlockTable value="{!results2}" var="pro" style="width:100%; border:1px solid #D4DADC;">
         
        <apex:column style="width:120px; padding-top:10px; padding-bottom:10px; text-align:center;" rendered="{!Filter == 'Show All'}">
            <apex:commandLink action="{!takeOwnership}" value="Take Ownership" styleClass="btn" style="text-decoration:none" rerender="table">
                <apex:param name="proId" value="{!pro.id}" />                          
            </apex:commandLink>
        </apex:column>
         
        <apex:column style="width:120px; padding-top:10px; padding-bottom:10px; text-align:center;" rendered="{!Filter != 'Show All'}">
            <apex:commandLink action="{!setStep}" value="View" styleClass="btn" style="text-decoration:none" rerender="table,mine">
                <apex:param name="proId" value="{!pro.id}" />                          
            </apex:commandLink>
        </apex:column>
        
        <apex:column headerValue="Owner" value="{!pro.Process_Owner__c}" rendered="{!Filter == 'Show Others' || Filter == 'Show Other Completed'}"/>
        <apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
        <apex:column headerValue="Reason for no Insurance" value="{!pro.Contact__r.Reason_for_no_Insurance__c}" 
                                            rendered="{!Filter == 'Show All' || Filter == 'Show Mine' || Filter == 'Show Others'}"/>
        <apex:column headerValue="Street Address" value="{!pro.Contact__r.MailingStreet}" 
                                            rendered="{!Filter == 'Show All' || Filter == 'Show Mine' || Filter == 'Show Others'}"/>
        <apex:column headerValue="City" value="{!pro.Contact__r.MailingCity}"/>
        <apex:column headerValue="Phone" value="{!pro.Contact__r.Phone}"/>
        <apex:column headerValue="Started On" value="{!pro.Start_Date__c}" 
                                            rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
        <apex:column headerValue="Completed On" value="{!pro.Completion_Date__c}" 
                                            rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
        <apex:column headerValue="Total Time (Days)" value="{!pro.Total_Process_Time__c}" 
                                            rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
        <apex:column headerValue="Outcome" value="{!pro.Outcome__c}" rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>  
    	<apex:facet name="footer">Showing Page # {!pageNumber} of {!totalPages}</apex:facet>
    
    </apex:pageBlockTable>
    </apex:pageBlockSection>
    </apex:outputpanel>
     
    
    
    </apex:pageblock>   
    </apex:outputpanel>
    
    <apex:outputPanel id="mine">    
    <apex:pageBlock title="Complete Insurance Profile for {!con.Name}" rendered="{!showStep == true}" mode="inlineEdit">
    <apex:pageBlockSection title="Process Details">
        <apex:outputField value="{!selectedProcess.Start_Date__c}"/>
        <apex:outputField value="{!selectedProcess.Total_Process_Time__c}"/>
        <apex:outputField value="{!selectedProcess.Outcome__c}"/>
    </apex:pageBlockSection>
        
    <apex:pageBlockButtons location="top">
        <apex:commandButton action="{!saveProcessChanges}" value="Save Changes" rerender="mine"/>
    </apex:pageBlockButtons>
    
    <apex:pageBlockTable value="{!MyStep}" var="step" style="width:100%; border:1px solid #D4DADC;" rendered="{!showStep == true}">
        <apex:column headerValue="Name" value="{!step.Name}"/>
        <apex:column headerValue="Assigned To" value="{!step.Assigned_To__c}"/>
        <apex:column headerValue="Status" value="{!step.Status__c}"/>       
        <apex:column headerValue="Complete" >
            <apex:outputtext value="{!step.Complete_Step_From_Process__c}" escape="false"/>
        </apex:column>
        <apex:column headerValue="Log Activity" >
            <apex:outputtext value="{!step.Log_Activity_From_Process__c}" escape="false"/>
        </apex:column>
        <apex:column headerValue="Create Task" >
            <apex:outputtext value="{!step.Create_Task_From_Process__c}" escape="false"/>
        </apex:column>  
        <apex:column headerValue="Completed By" value="{!step.Completed_by__c}"/>
        <apex:column headerValue="Date Completed" value="{!step.Date_Completed__c}"/>
                
    </apex:pageBlockTable>
    </apex:pageBlock>
    
    <apex:pageBlock title="Activities" rendered="{!showStep == true}">
    <apex:pageBlockTable value="{!stepActivities}" var="act" style="width:100%; border:1px solid #D4DADC;" rendered="{!stepActivities.size != 0}">
        <apex:column headerValue="Date" value="{!act.ActivityDate}"/>
        <apex:column headerValue="Owner" value="{!act.OwnerId}"/>
        <apex:column headerValue="Type" value="{!act.Subject}"/>
        <apex:column headerValue="Subject" value="{!act.Navigator_Subject__c}"/>
        <apex:column headerValue="Description" value="{!act.Description}"/> 
    </apex:pageBlockTable>
    <apex:outputText value="No Activities Recorded Yet" style="font-weight:bold;font-size:large;" rendered="{!stepActivities.size==0}"/>
    </apex:pageblock>
    </apex:outputPanel>
    
    </apex:outputpanel>
    </apex:form>

</apex:page>

 

Controller

 

public with sharing class InsuranceCampaignMasterController {
    
    public List<Process__c> results {get;set;}
    Transient List<Task> acts;
    public Process__c selectedProcess {get;set;}
    public String Filter {get;set;}
    public boolean showStep {get;set;}
    public Process_Step__c step;
    public Contact con {get;set;}
    public String listTitle {get;set;}
    private Id processTemplate;
    private Id cID;
    private Id userID; 
    
    private integer counter = 0;  //keeps track of the offset
    private integer listSize = 10; //sets the page size or number of rows
    public integer totalSize; //used to show user the total size of the list 

    public InsuranceCampaignMasterController() {
        
        Filter = 'Show All';
        ListTitle = 'Total Not Yet Claimed : ';      
        ShowStep = false;
        processTemplate = [Select Id From Process_Template__c Where Name = 'Insurance Profile Campaign'].id;
        cID = [Select Id, Name From User Where Name = 'Chris Duncombe'].id;
        userID = userinfo.getUserId();
        totalSize = [select count() from Process__c Where Process_Template__c =: processTemplate]; //set the total size in the constructor
    }

    
    public Process__c[] getResults2() {
    	String soql = 'Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone, '
                    + 'Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c, ' 
                    + 'Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__c = \'' + processTemplate + '\'';
        
                            
        if(Filter == 'Show All'){
          soql = soql +  ' and Process_Owner__c = \'' + cID + '\' and Status__c != \'Completed\' Order By Contact__r.LastName, '
          																						+ 'Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          												And Process_Owner__c =: cID And Status__c != 'Completed'];
        }
        if(Filter == 'Show Mine'){
          soql = soql +  ' and Process_Owner__c = \'' + userID + '\' and Status__c != \'Completed\' Order By Contact__r.LastName, '
          																						+ 'Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          												And Process_Owner__c =: userID And Status__c != 'Completed'];
        }
        if(Filter == 'Show Others') {
          soql = soql +  ' and Process_Owner__c != \'' +  userID + '\' and Process_Owner__c != \'' + cID
                            + '\' and Status__c != \'Completed\' Order By Process_Owner__r.Name, Contact__r.LastName, Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          									And Process_Owner__c !=: userID And Process_Owner__c !=: cID And Status__c != 'Completed'];
        }               
        if(Filter == 'Show My Completed'){
          soql = soql +  ' and Process_Owner__c = \'' + userID + '\' and Status__c = \'Completed\' Order By Contact__r.LastName, '
          																						+ 'Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          									And Process_Owner__c =: userID And Status__c = 'Completed'];
        }
        if(Filter == 'Show Other Completed') {
          soql = soql +  ' and Process_Owner__c != \'' + userID + '\' and Process_Owner__c != \'' + cID
                            + '\' and Status__c = \'Completed\' Order By Process_Owner__r.Name, Contact__r.LastName, Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          									And Process_Owner__c !=: userID And Process_Owner__c !=: cID And Status__c = 'Completed'];
        }     
            
        soql = soql + ' limit ' + ListSize + ' offset ' + counter;
        //System.debug(soql);        
        return database.query(soql);
    }
    
    public void takeOwnership() {
        
        selectedProcess = [Select Id, Name, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c 
                                    From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
                                    
        step = [Select Id, Name, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
        
        selectedProcess.Process_Owner__c = userinfo.getUserId();
        selectedProcess.Start_Date__c = system.today();
        step.Assigned_To__c = userinfo.getUserId();
        step.Status__c = 'Open';
        update selectedProcess;
        update step;
    }
    
    public void setStep() {
        
        showStep = true;
        selectedProcess = [Select Id, Name, Contact__c, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c
                                    From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
                                        
        step = [Select Id, Name, Process__c, Complete_Step_From_Process__c, Log_Activity_From_Process__c, Create_Task_From_Process__c, Status__c,
                                Completed_By__c, Date_Completed__c, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
        con = [Select Id, Name From Contact Where id =: SelectedProcess.Contact__c];
        acts = [Select Id, Subject, Navigator_Subject__c, ActivityDate, Description, WhoId, OwnerId, WhatId From Task Where WhatId =: step.id];  
  
    }  
    
    public process_Step__c getMyStep() {
        return step;
    }
    
    public List<Task> getStepActivities() {        
        return acts;
    }
    
    public void saveProcessChanges() {
        update selectedProcess;
    }
    
    public PageReference Beginning() { //user clicked beginning
      counter = 0;
      return null;
   }

   public PageReference Previous() { //user clicked previous button
      counter -= listSize;
      return null;
   }

   public PageReference Next() { //user clicked next button
      counter += listSize;
      return null;
   }

   public PageReference End() { //user clicked end
      counter = totalSize - math.mod(totalSize, listSize);
      return null;
   }

   public Boolean getDisablePrevious() { 
      //this will disable the previous and beginning buttons
      if (counter>0) return false; else return true;
   }

   public Boolean getDisableNext() { //this will disable the next and end buttons
      if (counter + listSize < totalSize) return false; else return true;
   }

   public Integer getTotalSize() {
      return totalSize;
   }

   public Integer getPageNumber() {
      return counter/listSize + 1;
   }

   public Integer getTotalPages() {
      if(totalSize == 0) {
      	return 1;
      }
      if (math.mod(totalSize, listSize) > 0) {
         return totalSize/listSize + 1;
      } else {
         return (totalSize/listSize);
      }
   }
    
    public void viewMine() {
        Filter = 'Show Mine';
        showStep = false;
        counter = 0;
        listTitle = 'Total Open By Me : ';        
    }
    public void viewAll() {
        Filter = 'Show All';
        showStep = false;
        counter = 0;
        listTitle = 'Total Not Yet Claimed : ';        
    }
    public void viewOthers() {
        Filter = 'Show Others';
        showStep = false;
        counter = 0;
        listTitle = 'Total Open By Others : ';        
    }   
    public void viewMyCompleted() {
        Filter = 'Show My Completed';
        showStep = false;
        counter = 0;
        listTitle = 'Total Completed By Me : ';        
    }
    public void viewOtherCompleted() {
        Filter = 'Show Other Completed';
        showStep = false;
        counter = 0;
        listTitle = 'Total Completed By Others : ';        
    }
}

 

Thanks for the responses ~ sfdcfox ~, you definitely got me going in the right direction with the dynamic table and the dynamic SOQL.  

 

Chris

 

All Answers

sfdcfoxsfdcfox

Your page is very inefficient, I expect you have a large(ish) view state as well.

 

How about this:

 

<apex:sectionHeader title="Insurance Profile Campaign" subtitle="Master List"/>
    <apex:form>
        <apex:outputpanel id="container">
            <apex:outputpanel id="table">	
                <apex:pageblock >
                    <apex:pageBlockButtons location="top">
                        <apex:commandLink action="{!viewAll}" value="View All Unassigned" styleClass="btn" style="text-decoration:none" id="all" rerender="table,mine,container"/>
                        <apex:commandLink action="{!viewMine}" value="View Mine (Open)" styleClass="btn" style="text-decoration:none" id="viewMine" rerender="table,mine,container"/>
                        <apex:commandLink action="{!viewOthers}" value="View Others (Open)" styleClass="btn" style="text-decoration:none" id="others" rerender="table,mine,container"/>
                        <apex:commandLink action="{!viewMyCompleted}" value="View Mine (Completed)" styleClass="btn" style="text-decoration:none" id="myComp" rerender="table,mine,container"/>
                        <apex:commandLink action="{!viewOtherCompleted}" value="View Others (Completed)" styleClass="btn" style="text-decoration:none" id="otherComp" rerender="table,mine,container"/>	
                    </apex:pageBlockButtons>
                
                    <apex:pageBlockTable value="{!processList}" var="pro" style="width:100%; border: 1px solid #DFDADC;">
                        <apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
                    </apex:pageBlockTable>
                </apex:pageblock>
        </apex:outputpanel>
    </apex:form>
</apex:page>

 

	Transient List<Task> acts;
	Public Process__c selectedProcess {get;set;}
	Public String Filter {get;set;}
	Public boolean showStep {get;set;}
	Public Process_Step__c step { get; set; }
	Public Contact con {get;set;} 	

	public InsuranceCampaignMasterController() {
		
		acts = new List<Task>();
		selectedProcess = new Process__c();
		step = new Process_Step__c();
		Filter = 'Show All';
		ShowStep = false;
		con = new Contact();
	}

	public List<Process__c> getProcessList() {
		if(Filter == 'Show All') {
			return [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__r.Name = 'Chris Duncombe' and Status__c != 'Completed' 
				Order By Contact__r.MailingCity ASC];
		}
		if(Filter == 'Show Mine') {
			return [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__c =: userinfo.getUserId() 
				and Status__c != 'Completed' Order By Start_Date__c ASC];
		}
		if(Filter == 'Show Others') {
			return [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c From Process__c 
				Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__c !=: userinfo.getUserId() 
				and Process_Owner__r.Name != 'Chris Duncombe' and Status__c != 'Completed' Order By Process_Owner__r.Name, Start_Date__c ASC];
		}
		if(Filter == 'Show My Completed') {
			return [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c,
				Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__r.Name = 'Insurance Profile Campaign' 
				and Process_Owner__c =: userinfo.getUserId() and Status__c = 'Completed' Order By Completion_Date__c];
		}
		if(Filter == 'Show Other Completed') {
			return [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c,
				Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__r.Name = 'Insurance Profile Campaign' 
				and Process_Owner__c !=: userinfo.getUserId() and Process_Owner__r.Name != 'Chris Duncombe' and Status__c = 'Completed'
				Order By Process_Owner__r.Name, Completion_Date__c ASC];
		}
		return null;
	}


	public void takeOwnership() {
		
		selectedProcess = [Select Id, Name, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c 
									From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
									
		step = [Select Id, Name, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		
		selectedProcess.Process_Owner__c = userinfo.getUserId();
		selectedProcess.Start_Date__c = system.today();
		step.Assigned_To__c = userinfo.getUserId();
		update selectedProcess;
		update step;
		myPros = null;		
	}
	
	public void setStep() {
		
		showStep = true;
		selectedProcess = [Select Id, Name, Contact__c, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c
				 					From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
										
		step = [Select Id, Name, Process__c, Complete_Step_From_Process__c, Log_Activity_From_Process__c, Create_Task_From_Process__c, Status__c,
								Completed_By__c, Date_Completed__c, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		con = [Select Id, Name From Contact Where id =: SelectedProcess.Contact__c];		
	}  
	
	public List<Task> getStepActivities() {
		return [Select Id, Subject, Navigator_Subject__c, ActivityDate, Description, WhoId, OwnerId, WhatId From Task Where WhatId =: step.id];
	}
	
	public void saveProcessChanges() {
		update selectedProcess;
	}
	
	private void setFilter(String filterName) {
		Filter = filterName;
		showStep = false;
	}
	
	public void viewMine() {
		setFilter('Show Mine');
	}
	
	public void viewAll() {
		setFilter('Show All');
	}
	
	public void viewOthers() {
		setFilter('Show Others');
	}
	
	public void viewMyCompleted() {
		setFilter('Show My Completed');
	}
	
	public void viewOtherCompleted() {
		setFilter('Show Other Completed');
	}
}

If you went with dynamic queries, you could get this code even smaller. But I think my current suggestions will provide a pretty heavy increase in speed.

cduncombe44cduncombe44

Thank you for the reply.  I took your advice and went a step further and built the SOQL dynamically, but the page is still just as slow

 

VF

<apex:pageBlockTable value="{!processes}" var="pro" style="width:100%; border:1px solid #D4DADC;">
		
		<apex:column style="width:120px; padding-top:10px; padding-bottom:10px; text-align:center;" rendered="{!Filter == 'Show All'}">
        	<apex:commandLink action="{!takeOwnership}" value="Take Ownership" styleClass="btn" style="text-decoration:none" rerender="table">
            	<apex:param name="proId" value="{!pro.id}" />                          
            </apex:commandLink>
        </apex:column>
        <apex:column style="width:120px; padding-top:10px; padding-bottom:10px; text-align:center;" rendered="{!Filter != 'Show All'}">
        	<apex:commandLink action="{!setStep}" value="View" styleClass="btn" style="text-decoration:none" rerender="table,mine">
            	<apex:param name="proId" value="{!pro.id}" />                          
            </apex:commandLink>
        </apex:column>
        <apex:column headerValue="Owner" value="{!pro.Process_Owner__c}" rendered="{!Filter == 'Show Others' || Filter == 'Show Other Completed'}"/>
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
		<apex:column headerValue="Reason for no Insurance" value="{!pro.Contact__r.Reason_for_no_Insurance__c}" 
											rendered="{!Filter == 'Show All' || Filter == 'Show Mine' || Filter == 'Show Others'}"/>
		<apex:column headerValue="Street Address" value="{!pro.Contact__r.MailingStreet}" 
											rendered="{!Filter == 'Show All' || Filter == 'Show Mine' || Filter == 'Show Others'}"/>
		<apex:column headerValue="City" value="{!pro.Contact__r.MailingCity}"/>
		<apex:column headerValue="Phone" value="{!pro.Contact__r.Phone}"/>
		<apex:column headerValue="Started On" value="{!pro.Start_Date__c}" 
											rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
		<apex:column headerValue="Completed On" value="{!pro.Completion_Date__c}" 
											rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
		<apex:column headerValue="Total Time (Days)" value="{!pro.Total_Process_Time__c}" 
											rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
		<apex:column headerValue="Outcome" value="{!pro.Outcome__c}" rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>	
	
	</apex:pageBlockTable>

 

Controller

public with sharing class InsuranceCampaignMasterController {
	
	List<Process__c> allPros;
	List<Process__c> myPros;
	List<Process__c> otherPros;
	List<Process__c> myCompletedPros;
	List<Process__c> otherCompletedPros;
	Transient List<Task> acts;
	Public Process__c selectedProcess {get;set;}
	Public String Filter {get;set;}
	Public boolean showStep {get;set;}
	Public Process_Step__c step;
	Public Contact con {get;set;} 	

	public InsuranceCampaignMasterController() {
		
		acts = new List<Task>();
		selectedProcess = new Process__c();
		step = new Process_Step__c();
		Filter = 'Show All';
		ShowStep = false;
		con = new Contact();
	}

	
	
	public List<Process__c> getProcesses(){
		return performSearch();
	}
	
	private List<Process__c> performSearch() {    
    
	    Id userID = userinfo.getUserId();
	    String soql = 'Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone, '
					+ 'Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c, ' 
					+ 'Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__r.Name = \'Insurance Profile Campaign\'';
	    					
	    if(Filter == 'Show All')
	      soql = soql +  ' and Process_Owner__r.Name = \'Chris Duncombe\' and Status__c != \'Completed\'';
	      
	    if(Filter == 'Show Mine')
	      soql = soql +  ' and Process_Owner__c = \'' + userID + '\' and Status__c != \'Completed\' Order By Start_Date__c ASC';
	     
	    if(Filter == 'Show Others') {
	      soql = soql +  ' and Process_Owner__c != \'' +  userID + '\' and Process_Owner__r.Name != \'Chris Duncombe\''
	      					+ ' and Status__c != \'Completed\' Order By Process_Owner__r.Name, Start_Date__c ASC';
	    }				
	    if(Filter == 'Show My Completed')
	      soql = soql +  ' and Process_Owner__c = \'' + userID + '\' and Status__c = \'Completed\' Order By Completion_Date__c';
	      
	    if(Filter == 'Show Other Completed') {
	      soql = soql +  ' and Process_Owner__c != \'' + userID + '\' and Process_Owner__r.Name != \'Chris Duncombe\''
	      					+ ' and Status__c = \'Completed\' Order By Process_Owner__r.Name, Completion_Date__c ASC';
	    }         
	    //soql = soql + ' limit 25';
	    //System.debug(soql);
	    return database.query(soql);     
    }
	
	public void takeOwnership() {
		
		selectedProcess = [Select Id, Name, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c 
									From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
									
		step = [Select Id, Name, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		
		selectedProcess.Process_Owner__c = userinfo.getUserId();
		selectedProcess.Start_Date__c = system.today();
		step.Assigned_To__c = userinfo.getUserId();
		update selectedProcess;
		update step;
		myPros = null;	
		allPros = null;	
	}
	
	public void setStep() {
		
		showStep = true;
		selectedProcess = [Select Id, Name, Contact__c, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c
				 					From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
										
		step = [Select Id, Name, Process__c, Complete_Step_From_Process__c, Log_Activity_From_Process__c, Create_Task_From_Process__c, Status__c,
								Completed_By__c, Date_Completed__c, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		con = [Select Id, Name From Contact Where id =: SelectedProcess.Contact__c];		
	}  
	
	public process_Step__c getMyStep() {
		return step;
	}
	
	public List<Task> getStepActivities() {
		acts = [Select Id, Subject, Navigator_Subject__c, ActivityDate, Description, WhoId, OwnerId, WhatId From Task Where WhatId =: step.id];
		return acts;
	}
	
	public void saveProcessChanges() {
		update selectedProcess;
	}
	
	public void viewMine() {
		Filter = 'Show Mine';
		showStep = false;
		
	}
	public void viewAll() {
		Filter = 'Show All';
		showStep = false;
		
	}
	public void viewOthers() {
		Filter = 'Show Others';
		showStep = false;
		
	}	
	public void viewMyCompleted() {
		Filter = 'Show My Completed';
		showStep = false;
		
	}
	public void viewOtherCompleted() {
		Filter = 'Show Other Completed';
		showStep = false;
		
	}
}

 

I agree this is must more neat and concise, but it really takes forever to query when you try to change the list.  Any ideas?

 

Chris

sfdcfoxsfdcfox

Try using the Developer Console to see how long the query is taking, and how much time is spent rendering. It should help you figure out what's going on.

cduncombe44cduncombe44

I generally use Eclipse.  How do I use the developer console to see query time vs. rendering time.  I have a feeling the time is in the rendering, not the query.  If that is the case, is there a better solution.  Would pagination help?

 

Chris

cduncombe44cduncombe44

 

I found that it was definitely a rendering issue, not a SOQL issue.  The constant rerendering of a DataTable with 1000 or so records was causing very slow ajax rerendering.

 

I was able to solve the problem through the suggestion of the dynamic query, as well as adding some pagination by using the OFFSET in my SOQL.  I was able to do this rather easily using this great blog post from RedPointSolutions

 

http://blog.redpointsolutions.com/bid/182738/Add-Pagination-to-your-Visualforce-Pages-using-the-SOQL-OFFSET-Clause

 

 

Heres the final code if anyone might be interested

 

 

VF

<apex:page controller="testController">

<apex:sectionHeader title="Insurance Profile Campaign" subtitle="Master List"/>
    <apex:form >
    <apex:outputpanel id="container">
    <apex:outputpanel id="table">   
    <apex:pageblock >
    <apex:pageBlockButtons location="top">
        <apex:commandLink action="{!viewAll}" value="View All Unassigned" styleClass="btn" style="text-decoration:none" id="all" rerender="container,table"/>
        <apex:commandLink action="{!viewMine}" value="View Mine (Open)" styleClass="btn" style="text-decoration:none" id="viewMine" rerender="container,table"/>
        <apex:commandLink action="{!viewOthers}" value="View Others (Open)" styleClass="btn" style="text-decoration:none" id="others" rerender="container,table"/>
        <apex:commandLink action="{!viewMyCompleted}" value="View Mine (Completed)" styleClass="btn" style="text-decoration:none" id="myComp" rerender="container,table"/>
        <apex:commandLink action="{!viewOtherCompleted}" value="View Others (Completed)" styleClass="btn" style="text-decoration:none" id="otherComp" rerender="container,table"/>    
    </apex:pageBlockButtons>
    </apex:pageblock>
    <apex:pageblock tabStyle="Account">
    <apex:pageBlockButtons location="top" >
    <apex:outputPanel id="myButtons">
   
        <apex:commandButton action="{!Beginning}" title="Beginning" value="<<" style="width:35px;" disabled="{!disablePrevious}" reRender="myPanel,myButtons"/>
        <apex:commandButton action="{!Previous}" title="Previous" value="<" style="width:25px;" disabled="{!disablePrevious}" reRender="myPanel,myButtons"/>        
        <apex:commandButton action="{!Next}" title="Next" value=">" style="width:25px;" disabled="{!disableNext}" reRender="myPanel,myButtons"/>
        <apex:commandButton action="{!End}" title="End" value=">>" style="width:35px;" disabled="{!disableNext}" reRender="myPanel,myButtons"/>        
   
    </apex:outputPanel>
    </apex:pageBlockButtons>
    
    
    <apex:outputpanel id="myPanel">
    <apex:pageBlockSection title="{!listTitle}({!totalSize})" collapsible="false" columns="1">
    <apex:pageBlockTable value="{!results2}" var="pro" style="width:100%; border:1px solid #D4DADC;">
         
        <apex:column style="width:120px; padding-top:10px; padding-bottom:10px; text-align:center;" rendered="{!Filter == 'Show All'}">
            <apex:commandLink action="{!takeOwnership}" value="Take Ownership" styleClass="btn" style="text-decoration:none" rerender="table">
                <apex:param name="proId" value="{!pro.id}" />                          
            </apex:commandLink>
        </apex:column>
         
        <apex:column style="width:120px; padding-top:10px; padding-bottom:10px; text-align:center;" rendered="{!Filter != 'Show All'}">
            <apex:commandLink action="{!setStep}" value="View" styleClass="btn" style="text-decoration:none" rerender="table,mine">
                <apex:param name="proId" value="{!pro.id}" />                          
            </apex:commandLink>
        </apex:column>
        
        <apex:column headerValue="Owner" value="{!pro.Process_Owner__c}" rendered="{!Filter == 'Show Others' || Filter == 'Show Other Completed'}"/>
        <apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
        <apex:column headerValue="Reason for no Insurance" value="{!pro.Contact__r.Reason_for_no_Insurance__c}" 
                                            rendered="{!Filter == 'Show All' || Filter == 'Show Mine' || Filter == 'Show Others'}"/>
        <apex:column headerValue="Street Address" value="{!pro.Contact__r.MailingStreet}" 
                                            rendered="{!Filter == 'Show All' || Filter == 'Show Mine' || Filter == 'Show Others'}"/>
        <apex:column headerValue="City" value="{!pro.Contact__r.MailingCity}"/>
        <apex:column headerValue="Phone" value="{!pro.Contact__r.Phone}"/>
        <apex:column headerValue="Started On" value="{!pro.Start_Date__c}" 
                                            rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
        <apex:column headerValue="Completed On" value="{!pro.Completion_Date__c}" 
                                            rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
        <apex:column headerValue="Total Time (Days)" value="{!pro.Total_Process_Time__c}" 
                                            rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>
        <apex:column headerValue="Outcome" value="{!pro.Outcome__c}" rendered="{!Filter == 'Show My Completed' || Filter == 'Show Other Completed'}"/>  
    	<apex:facet name="footer">Showing Page # {!pageNumber} of {!totalPages}</apex:facet>
    
    </apex:pageBlockTable>
    </apex:pageBlockSection>
    </apex:outputpanel>
     
    
    
    </apex:pageblock>   
    </apex:outputpanel>
    
    <apex:outputPanel id="mine">    
    <apex:pageBlock title="Complete Insurance Profile for {!con.Name}" rendered="{!showStep == true}" mode="inlineEdit">
    <apex:pageBlockSection title="Process Details">
        <apex:outputField value="{!selectedProcess.Start_Date__c}"/>
        <apex:outputField value="{!selectedProcess.Total_Process_Time__c}"/>
        <apex:outputField value="{!selectedProcess.Outcome__c}"/>
    </apex:pageBlockSection>
        
    <apex:pageBlockButtons location="top">
        <apex:commandButton action="{!saveProcessChanges}" value="Save Changes" rerender="mine"/>
    </apex:pageBlockButtons>
    
    <apex:pageBlockTable value="{!MyStep}" var="step" style="width:100%; border:1px solid #D4DADC;" rendered="{!showStep == true}">
        <apex:column headerValue="Name" value="{!step.Name}"/>
        <apex:column headerValue="Assigned To" value="{!step.Assigned_To__c}"/>
        <apex:column headerValue="Status" value="{!step.Status__c}"/>       
        <apex:column headerValue="Complete" >
            <apex:outputtext value="{!step.Complete_Step_From_Process__c}" escape="false"/>
        </apex:column>
        <apex:column headerValue="Log Activity" >
            <apex:outputtext value="{!step.Log_Activity_From_Process__c}" escape="false"/>
        </apex:column>
        <apex:column headerValue="Create Task" >
            <apex:outputtext value="{!step.Create_Task_From_Process__c}" escape="false"/>
        </apex:column>  
        <apex:column headerValue="Completed By" value="{!step.Completed_by__c}"/>
        <apex:column headerValue="Date Completed" value="{!step.Date_Completed__c}"/>
                
    </apex:pageBlockTable>
    </apex:pageBlock>
    
    <apex:pageBlock title="Activities" rendered="{!showStep == true}">
    <apex:pageBlockTable value="{!stepActivities}" var="act" style="width:100%; border:1px solid #D4DADC;" rendered="{!stepActivities.size != 0}">
        <apex:column headerValue="Date" value="{!act.ActivityDate}"/>
        <apex:column headerValue="Owner" value="{!act.OwnerId}"/>
        <apex:column headerValue="Type" value="{!act.Subject}"/>
        <apex:column headerValue="Subject" value="{!act.Navigator_Subject__c}"/>
        <apex:column headerValue="Description" value="{!act.Description}"/> 
    </apex:pageBlockTable>
    <apex:outputText value="No Activities Recorded Yet" style="font-weight:bold;font-size:large;" rendered="{!stepActivities.size==0}"/>
    </apex:pageblock>
    </apex:outputPanel>
    
    </apex:outputpanel>
    </apex:form>

</apex:page>

 

Controller

 

public with sharing class InsuranceCampaignMasterController {
    
    public List<Process__c> results {get;set;}
    Transient List<Task> acts;
    public Process__c selectedProcess {get;set;}
    public String Filter {get;set;}
    public boolean showStep {get;set;}
    public Process_Step__c step;
    public Contact con {get;set;}
    public String listTitle {get;set;}
    private Id processTemplate;
    private Id cID;
    private Id userID; 
    
    private integer counter = 0;  //keeps track of the offset
    private integer listSize = 10; //sets the page size or number of rows
    public integer totalSize; //used to show user the total size of the list 

    public InsuranceCampaignMasterController() {
        
        Filter = 'Show All';
        ListTitle = 'Total Not Yet Claimed : ';      
        ShowStep = false;
        processTemplate = [Select Id From Process_Template__c Where Name = 'Insurance Profile Campaign'].id;
        cID = [Select Id, Name From User Where Name = 'Chris Duncombe'].id;
        userID = userinfo.getUserId();
        totalSize = [select count() from Process__c Where Process_Template__c =: processTemplate]; //set the total size in the constructor
    }

    
    public Process__c[] getResults2() {
    	String soql = 'Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone, '
                    + 'Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c, Start_Date__c, Completion_Date__c, ' 
                    + 'Total_Process_Time__c, Outcome__c From Process__c Where Process_Template__c = \'' + processTemplate + '\'';
        
                            
        if(Filter == 'Show All'){
          soql = soql +  ' and Process_Owner__c = \'' + cID + '\' and Status__c != \'Completed\' Order By Contact__r.LastName, '
          																						+ 'Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          												And Process_Owner__c =: cID And Status__c != 'Completed'];
        }
        if(Filter == 'Show Mine'){
          soql = soql +  ' and Process_Owner__c = \'' + userID + '\' and Status__c != \'Completed\' Order By Contact__r.LastName, '
          																						+ 'Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          												And Process_Owner__c =: userID And Status__c != 'Completed'];
        }
        if(Filter == 'Show Others') {
          soql = soql +  ' and Process_Owner__c != \'' +  userID + '\' and Process_Owner__c != \'' + cID
                            + '\' and Status__c != \'Completed\' Order By Process_Owner__r.Name, Contact__r.LastName, Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          									And Process_Owner__c !=: userID And Process_Owner__c !=: cID And Status__c != 'Completed'];
        }               
        if(Filter == 'Show My Completed'){
          soql = soql +  ' and Process_Owner__c = \'' + userID + '\' and Status__c = \'Completed\' Order By Contact__r.LastName, '
          																						+ 'Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          									And Process_Owner__c =: userID And Status__c = 'Completed'];
        }
        if(Filter == 'Show Other Completed') {
          soql = soql +  ' and Process_Owner__c != \'' + userID + '\' and Process_Owner__c != \'' + cID
                            + '\' and Status__c = \'Completed\' Order By Process_Owner__r.Name, Contact__r.LastName, Contact__r.FirstName';
          totalSize = [Select count() From Process__c Where Process_Template__c =: processTemplate 
          									And Process_Owner__c !=: userID And Process_Owner__c !=: cID And Status__c = 'Completed'];
        }     
            
        soql = soql + ' limit ' + ListSize + ' offset ' + counter;
        //System.debug(soql);        
        return database.query(soql);
    }
    
    public void takeOwnership() {
        
        selectedProcess = [Select Id, Name, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c 
                                    From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
                                    
        step = [Select Id, Name, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
        
        selectedProcess.Process_Owner__c = userinfo.getUserId();
        selectedProcess.Start_Date__c = system.today();
        step.Assigned_To__c = userinfo.getUserId();
        step.Status__c = 'Open';
        update selectedProcess;
        update step;
    }
    
    public void setStep() {
        
        showStep = true;
        selectedProcess = [Select Id, Name, Contact__c, Process_Owner__c, Start_Date__c, Completion_Date__c, Total_Process_Time__c, Outcome__c
                                    From Process__c Where Id =: system.currentPageReference().getParameters().get('proId')];
                                        
        step = [Select Id, Name, Process__c, Complete_Step_From_Process__c, Log_Activity_From_Process__c, Create_Task_From_Process__c, Status__c,
                                Completed_By__c, Date_Completed__c, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
        con = [Select Id, Name From Contact Where id =: SelectedProcess.Contact__c];
        acts = [Select Id, Subject, Navigator_Subject__c, ActivityDate, Description, WhoId, OwnerId, WhatId From Task Where WhatId =: step.id];  
  
    }  
    
    public process_Step__c getMyStep() {
        return step;
    }
    
    public List<Task> getStepActivities() {        
        return acts;
    }
    
    public void saveProcessChanges() {
        update selectedProcess;
    }
    
    public PageReference Beginning() { //user clicked beginning
      counter = 0;
      return null;
   }

   public PageReference Previous() { //user clicked previous button
      counter -= listSize;
      return null;
   }

   public PageReference Next() { //user clicked next button
      counter += listSize;
      return null;
   }

   public PageReference End() { //user clicked end
      counter = totalSize - math.mod(totalSize, listSize);
      return null;
   }

   public Boolean getDisablePrevious() { 
      //this will disable the previous and beginning buttons
      if (counter>0) return false; else return true;
   }

   public Boolean getDisableNext() { //this will disable the next and end buttons
      if (counter + listSize < totalSize) return false; else return true;
   }

   public Integer getTotalSize() {
      return totalSize;
   }

   public Integer getPageNumber() {
      return counter/listSize + 1;
   }

   public Integer getTotalPages() {
      if(totalSize == 0) {
      	return 1;
      }
      if (math.mod(totalSize, listSize) > 0) {
         return totalSize/listSize + 1;
      } else {
         return (totalSize/listSize);
      }
   }
    
    public void viewMine() {
        Filter = 'Show Mine';
        showStep = false;
        counter = 0;
        listTitle = 'Total Open By Me : ';        
    }
    public void viewAll() {
        Filter = 'Show All';
        showStep = false;
        counter = 0;
        listTitle = 'Total Not Yet Claimed : ';        
    }
    public void viewOthers() {
        Filter = 'Show Others';
        showStep = false;
        counter = 0;
        listTitle = 'Total Open By Others : ';        
    }   
    public void viewMyCompleted() {
        Filter = 'Show My Completed';
        showStep = false;
        counter = 0;
        listTitle = 'Total Completed By Me : ';        
    }
    public void viewOtherCompleted() {
        Filter = 'Show Other Completed';
        showStep = false;
        counter = 0;
        listTitle = 'Total Completed By Others : ';        
    }
}

 

Thanks for the responses ~ sfdcfox ~, you definitely got me going in the right direction with the dynamic table and the dynamic SOQL.  

 

Chris

 

This was selected as the best answer